How do I check if a function got CTFE?

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 2 11:17:11 PDT 2014


On Thursday, 2 October 2014 at 17:56:29 UTC, AsmMan wrote:
> I'd like to check if a function got CTFE, ie, the compiler was 
> able to replace my foo(s); by the computed value at 
> compile-time.
>
> I'm trying to convert the binary executable to assembly by 
> using objconv tool but I'm finding it very diffucult to find 
> anything in there, since some converters I've used which does 
> ELF to ASM keep the function name, e.g, foo() function is a foo 
> label somewhere in the file but this convert doesn't and use 
> some numbers instead of. I don't know if it's related how is 
> the windows object file format designed.

Sorry, can't help with you objconv, COFF, ELF, etc.

A little something about terminology though: "CTFE" in the
narrower sense refers to those occurrences of compile time
evaluation that are specified to happen. Static initializers are
CTFE-ed, for example. CTFE is not an optimization that a compiler
may or may not do.

The term for the optimization would be "constant folding", I
think. Your question, as I understand it, is about constant
folding, not about CTFE.


More information about the Digitalmars-d-learn mailing list