-
Notifications
You must be signed in to change notification settings - Fork 5
Description
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:
- Simple case: https://cppx.godbolt.org/z/58ced4
- Minor whitespace change of moving
main's{: https://cppx.godbolt.org/z/e1e1cG - Minor renaming from
move_intof: https://cppx.godbolt.org/z/bf363e - Both renaming the function and moving the
{: https://cppx.godbolt.org/z/3qcWP4
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.