Bug 8396 – wrong order of evaluation for tuple expansion in function arguments
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-17T06:03:00Z
Last change time
2013-11-25T08:20:09Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2012-07-17T06:03:32Z
cat > bug.d << CODE
struct Tuple { int _a, _b; }
Tuple foo() { return Tuple(1, 2); }
extern(C) int bar(int a, int b)
{
return b - a;
}
void main()
{
assert(bar(foo().tupleof) == 1);
}
CODE
dmd -run bug
----
Arguments for extern(C) function are currently evaluated from right to left (Bug 6620). The temporary for the result of foo is evaluated with the leftmost argument, therefore the second argument is uninitialized when calling an extern(C) function.