Compile-time evaluation of real expressions?

Alex Rønne Petersen xtzgzorex at
Fri Jan 6 15:49:46 PST 2012

On 07-01-2012 00:37, Jonathan M Davis wrote:
> On Saturday, January 07, 2012 00:03:39 Alex Rønne Petersen wrote:
>> Most likely those functions are just implemented using inline assembly,
>> therefore not usable in CTFE.
> Yeah, several functions in std.math use inline assembly. So, for them to be
> able to be used at compile time, either the compiler must be expanded to be
> able to run asm statements at compile time (which may or may not be planned
> and may or may not be reasonable), or those functions need another branch
> (using __cfte in an if condition) which doesn't use assembly. Or I suppose
> that if the extra check for __ctfe isn't considered particularly acceptable
> (after all, they're already using assembly), then separate functions meant
> specifically for CTFE would be necessary. I don't know what Don's preferred
> approach would be, but presumably, it would be up to him since he's the
> primary maintainer of both CTFE and std.math.
> An enhancement request for it should probably be opened:
> - Jonathan M Davis

Allowing asm in CTFE would probably be way more work than it's worth. 
You'd basically need full-blown analysis of x86 assembly plus an 
interpreter. Even then, x86 is not typed, so it's going to be a major 

- Alex

More information about the Digitalmars-d-learn mailing list