Heisenbug when compiling f(move auto a, in auto b)
invoked with f(move(s), s)
#16
Labels
prototype-bug
Something isn't working
The basic case is:
This bug seems fragile... each of the following repros sometimes crashes the compiler, sometimes fails compilation without crashing, and sometimes succeeds:
main
's{
: https://cppx.godbolt.org/z/e1e1cGmove_in
tof
: https://cppx.godbolt.org/z/bf363e{
: https://cppx.godbolt.org/z/3qcWP4Just 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
(thecopy_from(a,b)
call) moves froma
, and becauseb
is passed by pointer (so will aliasa
in this code) and the evaluation ofa
andb
are not indeterminately sequenced then the evaluation ofb
should copy either the original or moved-from state of the object.The text was updated successfully, but these errors were encountered: