What the heck is wrong with CTFE's?

John Colvin john.loughran.colvin at gmail.com
Mon Jul 8 05:54:24 PDT 2013


On Monday, 8 July 2013 at 12:08:39 UTC, Dicebot wrote:
> On Monday, 8 July 2013 at 11:56:40 UTC, JS wrote:
>> ...
>
> CTFE has nothing to do with it.
>
> void main()
> {
>         import std.stdio;
> 	int i = 0;	
> 	writeln(i == 0 ? i : i++);
> 	writeln(i);
> }
>
> "i++" is evaluated lazy here. I don't know if it is a bug or 
> matches the spec.

Nothing wrong with that. It's the normal behaviour in C, and it 
makes perfect sense if you just expand the ternary out to if/else.


More information about the Digitalmars-d mailing list