[Bug c++/116459] gcc 12.2.0 optimized out functions which has observable side affect

2024-08-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459 --- Comment #8 from Jonathan Wakely --- (In reply to xiaohuba2021 from comment #0) > struct Matrix { > long long mat[2][2]; > Matrix() { memset(mat, 0, sizeof(mat)); } N.B. there's no miscompilation if you change this to the more idioma

[Bug c++/116459] gcc 12.2.0 optimized out functions which has observable side affect

2024-08-22 Thread xiaohuba2021 at 163 dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459 --- Comment #7 from xiaohuba2021 --- Created attachment 58975 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58975&action=edit The miscompiled program

[Bug c++/116459] gcc 12.2.0 optimized out functions which has observable side affect

2024-08-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459 --- Comment #6 from Jonathan Wakely --- Regression started with with r12-2523 and was fixed by r13-7206, which was backported as r12-9476. So this is a dup of either PR ipa/107769 or PR ipa/109318.

[Bug c++/116459] gcc 12.2.0 optimized out functions which has observable side affect

2024-08-22 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459 Sam James changed: What|Removed |Added CC||sjames at gcc dot gnu.org --- Comment #5 fr

[Bug c++/116459] gcc 12.2.0 optimized out functions which has observable side affect

2024-08-22 Thread xiaohuba2021 at 163 dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459 --- Comment #4 from xiaohuba2021 --- Yes, it seems that only 12.1 and 12.2 are affected. But I wonder what's the cause of it, and are there any patches for it?

[Bug c++/116459] gcc 12.2.0 optimized out functions which has observable side affect

2024-08-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459 Richard Biener changed: What|Removed |Added Known to fail||12.1.0, 12.2.0 Known to work|

[Bug c++/116459] gcc 12.2.0 optimized out functions which has observable side affect

2024-08-22 Thread xiaohuba2021 at 163 dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459 --- Comment #2 from xiaohuba2021 --- > Uncomment line 20 (mask = 1) or explicitly add operator= for struct Matrix > solves this problem. sorry, the code above produces the correct answer, since line 20 is uncommented. Comment it and it will ou