Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 16408 - [REG2.065] left-to-right order of evaluation of fun… #6705

Merged
merged 1 commit into from
Apr 18, 2017

Conversation

WalterBright
Copy link
Member

…ction arguments not consistently followed

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
16408 [REG2.065] left-to-right order of evaluation of function arguments not consistently followed

@WalterBright WalterBright force-pushed the fix16408 branch 13 times, most recently from 2965cfd to e6a4812 Compare April 17, 2017 04:41
@WalterBright
Copy link
Member Author

This PR makes left-to-right evaluation of function arguments much more consistent than before. While this is in more conformance with the D spec, it may break some existing code that inadvertently had a dependency of r-t-l evaluation. It is impractical for the compiler to detect this (good 'ole halting problem).

@andralex
Copy link
Member

Can we then close the order of evaluation matter, or there are a few stragglers left?

@@ -182,10 +182,10 @@ elem *callfunc(Loc loc,
ty = ec.Ety;
if (fd)
ty = toSymbol(fd).Stype.Tty;
reverse = tyrevfunc(ty);
reverse = tyrevfunc(ty); // left-to-right parameter evaluation (TYnpfunc, TYjfunc, TYfpfunc, TYf16func)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long comment

elem*[5] elems_array = void;
import core.stdc.stdlib : malloc, free;
auto elems = (n <= 5) ? elems_array.ptr : cast(elem**)malloc(arguments.dim * (elem*).sizeof);
assert(elems);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nicer to use this instead of relying on code downstream:

scope(exit) if (n > 5) free(elems);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've avoided that form because the intervening code is not nothrow, meaning it sets up an EH frame even though the intervening code will never throw.

* D presumes left-to-right argument evaluation, but we're evaluating things
* right-to-left here.
* 1. determine if this matters
* 2. fix it if it does
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does matter... best to keep to the spec and keep the spec simple

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that foo(3,4) does not have order of evaluation issues.

@WalterBright
Copy link
Member Author

There may be a couple other OOE issues, but this should fix the biggie.

@WalterBright
Copy link
Member Author

Auto-merge toggled on

@WalterBright WalterBright merged commit 630831f into dlang:master Apr 18, 2017
@MartinNowak
Copy link
Member

This apparently introduced a regression Issue 17356 – [Reg 2.075] __simd_sto no longer executed @WalterBright, yet another backend issue sabotaging the arrayops rewrite :/.

@UplinkCoder
Copy link
Member

@WalterBright r-t-l order makes more sense for function calls.
Rather then fixing the compilers correct behavior we should fix the spec.

@WalterBright WalterBright deleted the fix16408 branch May 9, 2017 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants