LDC 1.0.0-alpha1 has been released! Please help testing!

Andrea Fontana via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Mon Feb 29 07:24:29 PST 2016


On Monday, 29 February 2016 at 15:19:19 UTC, Johan Engelen wrote:
> On Monday, 29 February 2016 at 14:47:58 UTC, Andrea Fontana 
> wrote:
>> On Monday, 29 February 2016 at 13:36:59 UTC, kink wrote:
>>> I hope LDC computes tst = 20. ;)
>>> Iirc, there were some inconsistencies wrt. this. LDC and GDC 
>>> do it one way (the proper one imo), dmd another way.
>>
>> "Proper" depends on specs. If is an undefined behaviour i 
>> think it should be defined or a warning should be triggered
>
> Spec:
> https://dlang.org/spec/expression.html#order-of-evaluation
>
> Strict left-to-right order evaluation, as the spec prescribes, 
> would give tst=20.
> Is there a DMD bug report for this? I didn't test with DMD, but 
> if tst!=20, it is a pretty severe issue.

Dmd gives 20. Ldc gives 21:

andrea at ububocs:/tmp$ cat tmp.d
import std.stdio;

void main()
{

	size_t inc(size_t* v)
	{
    		(*v)++;
    		return 10;
	}


	size_t pos = 10;
	
	immutable tst = pos + inc(&pos); // <-- this
	writeln(tst);
	writeln(pos);
}
andrea at ububocs:/tmp$ rdmd tmp.d
20
11
andrea at ububocs:/tmp$ ldc2 tmp.d && ./tmp
21
11




More information about the digitalmars-d-ldc mailing list