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.
Comment #2 by johannespfau — 2014-02-13T00:22:04Z
The pull request was accepted, LTR evaluation is now required: https://github.com/D-Programming-Language/dlang.org/pull/6
Comment #3 by k.hara.pg — 2014-10-01T06:35:25Z
Comment #4 by k.hara.pg — 2014-10-01T13:04:30Z
(In reply to Kenji Hara from comment #3) > https://github.com/D-Programming-Language/dmd/pull/4035 A small supplemental documentation fix: https://github.com/D-Programming-Language/dlang.org/pull/669
Comment #5 by iamthewilsonator — 2018-11-24T11:14:12Z
2.074.1: Failure with output: ----- [email protected](13): Assertion failure ---------------- ??:? _d_assertp [0x42750d] onlineapp.d:13 _Dmain [0x427447] ??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFNlZv [0x427857] ??:? scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x427787] ??:? scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x427800] ??:? scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x427787] ??:? _d_run_main [0x4276f7] ??:? main [0x42746d] ??:? __libc_start_main [0x4218982f] ----- Since 2.075.1: Success and no output