November 02, 2018 Re: Fun surprising things | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Friday, 2 November 2018 at 08:15:28 UTC, Kagamin wrote: > On Wednesday, 31 October 2018 at 14:54:48 UTC, Patrick Schluter wrote: >> 01 is the other possible result. It all depends in what order a and b are called. ~ is not a sequence point (does D even have that typical C notion of sequence points?) so the order of evaluation is at the discretion of the compiler. > > In C function call is a sequence point, undefined order applies only to expressions without sequence points. Yes, but irrelevant here. f(g(x), h(y)) doesn't mandate in which order g(x) and h(y) are evaluated even though x will be evaluated before g is called and y before h is called. That's all the sequence point of function call can do (btw, I wouldn't rely, in C, on that sequence point as inlining often breaks it). >BTW to!string > allocates memory from GC which involves a mutex lock, which can't possibly have undefined order. Same remark, doesn't change anything. f(g(x), h(y)) only garantees these 2 orders push x sequence point call g push g(x) push y sequence point call h push h(y) sequence point call f or push y sequence point call h push h(y) push x sequence point call g push g(x) sequence point call f theoretically also parallel evaluation of g(x) and h(y) but in practice I've never seen it. But all this is moot as D is not C and the specs of D mandate the order of evaluation for ~. dmd and gdc clearly violate the specs and either the specs are loosened or the compiler is corrected. |
November 03, 2018 Re: Fun surprising things | ||||
---|---|---|---|---|
| ||||
Posted in reply to Patrick Schluter | On Friday, 2 November 2018 at 09:27:50 UTC, Patrick Schluter wrote:
>
> But all this is moot as D is not C and the specs of D mandate the order of evaluation for ~. dmd and gdc clearly violate the specs and either the specs are loosened or the compiler is corrected.
Indeed.
We found this a very serious bug and made LDC respect this part of the language specification since version 1.8.0.
If you still find cases where LDC does not respect strict left-to-right evaluation order, please file a bug with LDC, thanks!
-Johan
|
November 03, 2018 Re: Fun surprising things | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Wednesday, 31 October 2018 at 22:54:50 UTC, Timon Gehr wrote:
> I think you are the one who is misreading the spec here.
Indeed. I'm sorry, I'm gonna go stand in that shaming corner for a while...
|
Copyright © 1999-2021 by the D Language Foundation