[Bug c++/107161] gcc doesn't constant fold member if any other member is mutable
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107161 --- Comment #2 from Ivan Sorokin --- > Do constexpr/consteval work in such circumstances? Yes, constexpr works for variables like "p.a": extern constexpr mytype p = {1, 2}; int foo() { constexpr int t = p.a + 10; return t; } foo(): mov eax, 11 ret https://godbolt.org/z/K9a69E4ar
[Bug c++/107161] gcc doesn't constant fold member if any other member is mutable
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107161 --- Comment #1 from Richard Biener --- GCC relies on 'p' being in .rodata for the folding which of course cannot be the case with a mutable member. Note the frontend clears the 'const' from the declaration because of the mutable member and we have no way to distinguish constant from non-constant members here. Do constexpr/consteval work in such circumstances?
[Bug c++/107161] gcc doesn't constant fold member if any other member is mutable
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107161 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement Keywords||missed-optimization