Compile-time vs. compile-time

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jan 5 00:02:48 UTC 2018


On Thu, Jan 04, 2018 at 04:57:25PM -0700, Jonathan M Davis via Digitalmars-d wrote:
> On Thursday, January 04, 2018 14:59:44 H. S. Teoh via Digitalmars-d wrote:
[...]
> > Are you sure that's non-CTFE?  Isn't standard constant folding a
> > part of CTFE?  Anyway, the new section should clear up the
> > confusion.
> 
> As I understand it, CTFE and constant folding aren't really related at
> all.  Obviously, a value that was generated as part of CTFE could then
> take part in constant folding if appropriate, because once the value
> is generated, it really isn't any different from if that value were
> written by hand. However, CTFE is never done as a compiler
> optimization. It's only ever done because a value is required at
> compile time. So, constant folding won't even trigger CTFE, just like
> the compiler will never decide that it might be more efficient to call
> a function at compile time and thus call it at compile time instead of
> runtime.
[...]

Ah, I see. That clears up some misunderstanding on my part. I'll update
the article accordingly. Thanks!


T

-- 
Chance favours the prepared mind. -- Louis Pasteur


More information about the Digitalmars-d mailing list