Bug 6620 – argument evaluation order inversed for extern(C)
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-09-07T16:05:10Z
Last change time
2018-11-24T11:14:12Z
Keywords
pull, wrong-code
Assigned to
No Owner
Creator
Martin Nowak
Comments
Comment #0 by code — 2011-09-07T16:05:10Z
version (none)
{
extern(C) int bar(int a, int b) { return b - a; }
}
else
{
int bar(int a, int b) { return b - a; }
}
void main()
{
int i;
assert(bar(++i, ++i) == 1);
}
---
I know argument evaluation order isn't really guaranteed to be left to right.
But having a reverse order for extern(C) calls is simply surprising.
Comment #1 by yebblies — 2011-09-07T21:30:51Z
(In reply to comment #0)
> I know argument evaluation order isn't really guaranteed to be left to right.
It isn't guaranteed _at all_, it's undefined. I think there's already an enhancement open about defining the order of evaluation, but until that's accepted this is perfectly valid behavior by the compiler.