[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting
raffael at casagrande dot ch
gcc-bugzilla@gcc.gnu.org
Fri Mar 8 12:58:57 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307
--- Comment #7 from Raffael Casagrande <raffael at casagrande dot ch> ---
@Jonathan Wakely Thanks very much for the detailed analysis. But there is one
point which I don't understand:
> BUT, the self-referential pointer is set to the address of the range_ member
> before the return value is copied, and so goes out of scope when that object
> is copied via registers and then copied again into the automatic variable
> in main().
I can't follow/understand how Next() is called before the return value is
copied.
If we look at the constructor of EnumeratorRange, we see that `enumerator_` is
initialized before end_reached_.
And afterwards the enumerator_ is not moved/copied anymore because of copy
elision? This can be verified by adding some extra print statements to the
copy/move constructor of Enumerator.
More information about the Gcc-bugs
mailing list