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

Heisenbug when compiling f(move auto a, in auto b) invoked with f(move(s), s) #16

Open
hsutter opened this issue Nov 30, 2020 · 0 comments
Assignees
Labels
prototype-bug Something isn't working

Comments

@hsutter
Copy link
Owner

hsutter commented Nov 30, 2020

The basic case is:

void move_in(move auto a, in auto b) { copy_from(a, b); }
// ...
move_in(std::move(s), s);

This bug seems fragile... each of the following repros sometimes crashes the compiler, sometimes fails compilation without crashing, and sometimes succeeds:

Just keep hitting Godbolt's "clear cache and recompile" button, and the answer for each changes from run to run of the compiler.

Original report: https://www.reddit.com/r/cpp/comments/j8tf9k/empirically_measuring_reducing_cs_accidental/g8zfd9x/

Note that with the Lifetime rules we'd get a warning that the two arguments alias. Still, even without that diagnostic we should not crash, but still translate the well-formed program with the semantics that the last use of parameter a (the copy_from(a,b) call) moves from a, and because b is passed by pointer (so will alias a in this code) and the evaluation of a and b are not indeterminately sequenced then the evaluation of b should copy either the original or moved-from state of the object.

@hsutter hsutter added the prototype-bug Something isn't working label Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prototype-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants