[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-23 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #19 from Jonathan Wakely --- I still think this is just invalid, for the reasons given in comment 5.

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-23 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #17 from Andrew Pinski --- Note the original didn't: ``` auto b = range_.begin(); bool result = (b != range_.end()); begin_ = std::move(b); return result; ```

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-23 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #16 from Andrew Pinski --- The reduced testcase has an uninitialized variable in it: ``` if (!begin_.has_value()) { bool result; return result; } ``` This might be the issue overall.

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-23 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #18 from Andrew Pinski --- For the reduced testcase: ``` : In member function 'auto Intersections()::Enumerator::Next()': :65:16: warning: 'result' may be used uninitialized [-Wmaybe-uninitialized] 65 | return result;

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-23 Thread mcccs at gmx dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #15 from mcccs at gmx dot com --- Thanks Jonathan for -x c++, it was just what GCC on my system needed

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-23 Thread mcccs at gmx dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #14 from mcccs at gmx dot com --- Created attachment 61179 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61179&action=edit reduced.cpp I think this reduction is valid. Fails with -O1 -fcode-hoisting, doesn't fail with -O0 or -

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #13 from Jonathan Wakely --- Ah but the filename x.cpp does imply C++. Still, the commands work for me (with just a -Wnon-template-friend warning).

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-21 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #12 from Jonathan Wakely --- You need -x c++ for the first command, otherwise the preprocessor runs as C and will not have any C++ macros (like --cplusplus) defined. g++ -E does *not* imply C++

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2025-04-21 Thread mcccs at gmx dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 mcccs at gmx dot com changed: What|Removed |Added CC||mcccs at gmx dot com --- Comment

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2024-03-08 Thread raffael at casagrande dot ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #10 from Raffael Casagrande --- (In reply to Jonathan Wakely from comment #9) Thanks very much! I missed the part with the trivial copy constructor and learned again an important lesson. That explains why it works when I defined the

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2024-03-08 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #9 from Jonathan Wakely --- Ironically, writing a user-provided (and so non-trivial) copy constructor which fixes up the self-referential pointer (or iterator, in your case) will restore guaranteed elision, and that copy constructor

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2024-03-08 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #8 from Jonathan Wakely --- I explained this in PR 109945 comment 25 There is no guaranteed copy elision for objects with a trivial copy constructor and trivial (or deleted) destructor. The compiler is allowed to make temporary copi

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2024-03-08 Thread raffael at casagrande dot ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #7 from Raffael Casagrande --- @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 th

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2024-03-05 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #6 from Richard Biener --- Thanks, so keeping this open but it will likely end up INVALID.

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2024-03-05 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 --- Comment #5 from Jonathan Wakely --- return EnumeratorRange(Enumerator(std::views::single(Intersection(; This creates a temporary Intersection object, then copies that into a single_view object. Then that is copied into an Enumerator o

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2024-03-05 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 Richard Biener changed: What|Removed |Added CC||redi at gcc dot gnu.org --- Comment #4

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2023-10-31 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 Richard Biener changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2023-10-31 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 Richard Biener changed: What|Removed |Added CC||jamborm at gcc dot gnu.org --- Comment

[Bug tree-optimization/112307] Segmentation fault with -O1 -fcode-hoisting

2023-10-31 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112307 Richard Biener changed: What|Removed |Added CC||rguenth at gcc dot gnu.org Last reco