[Bug c/115768] [C23] constexpr array of string literals not optimized

2024-07-03 Thread biggs at biggs dot xyz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768 --- Comment #7 from biggs at biggs dot xyz --- (In reply to Andrew Pinski from comment #2) > For C++ (well with GCC extensions obvious) this would be valid: > ``` > static constexpr const char *names[] = { > [CE_RED] = "RED", > [CE_GREEN]

[Bug c/115768] [C23] constexpr array of string literals not optimized

2024-07-03 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768 --- Comment #6 from Andrew Pinski --- (In reply to biggs from comment #5) > So the argument here is that C23's constexpr does not permit this > optimization because it does not allow constexpr pointers other than nullptr? No I am saying the fol

[Bug c/115768] [C23] constexpr array of string literals not optimized

2024-07-03 Thread biggs at biggs dot xyz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768 --- Comment #5 from biggs at biggs dot xyz --- (In reply to Andrew Pinski from comment #4) > (In reply to biggs from comment #3) > > > > The unused names are optimized out here and string_view is simply a > > contiguous array of characters not p

[Bug c/115768] [C23] constexpr array of string literals not optimized

2024-07-03 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768 --- Comment #4 from Andrew Pinski --- (In reply to biggs from comment #3) > > The unused names are optimized out here and string_view is simply a > contiguous array of characters not pointers. Nope, it is still an array of pointers (and length

[Bug c/115768] [C23] constexpr array of string literals not optimized

2024-07-03 Thread biggs at biggs dot xyz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768 --- Comment #3 from biggs at biggs dot xyz --- (In reply to Andrew Pinski from comment #1) > >The unused constexpr names aren't optimized out but the const*const ones are. > > > They are different. > In the constexpr case, you have an array of

[Bug c/115768] [C23] constexpr array of string literals not optimized

2024-07-03 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768 --- Comment #2 from Andrew Pinski --- For C++ (well with GCC extensions obvious) this would be valid: ``` static constexpr const char *names[] = { [CE_RED] = "RED", [CE_GREEN] = "GREEN", [CE_BLUE] = "BLUE", }; ``` And gets optimized

[Bug c/115768] [C23] constexpr array of string literals not optimized

2024-07-03 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768 Andrew Pinski changed: What|Removed |Added Resolution|--- |INVALID Status|UNCONFIRMED