[Bug c++/108626] GCC doesn't deduplicate string literals for const char*const and const char[]

2023-02-02 Thread marat at slonopotamus dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626 --- Comment #8 from Marat Radchenko --- Also, quote from C17 standard: Like string literals, const-qualified compound literals can be placed into read-only memory and *can even be shared*. (6.5.2.5 p 13).

[Bug c++/108626] GCC doesn't deduplicate string literals for const char*const and const char[]

2023-02-02 Thread marat at slonopotamus dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626 --- Comment #7 from Marat Radchenko --- While playing with it more, I found that clang behaves in a very strange way. While they do combine `const char* const` + `const char[]`, the DO NOT combine two `const char[]` together. I don't have any ex

[Bug c++/108626] GCC doesn't deduplicate string literals for const char*const and const char[]

2023-02-02 Thread marat at slonopotamus dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626 --- Comment #5 from Marat Radchenko --- So, does "String literals, and compound literals with const-qualified types, need not designate distinct objects." apply here or not? If not, how does the case where it applies look like? https://en.cppre

[Bug c++/108626] GCC doesn't deduplicate string literals for const char*const and const char[]

2023-02-01 Thread marat at slonopotamus dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626 --- Comment #2 from Marat Radchenko --- Thanks for the pointer to -fmerge-all-constants, that helped me to google out why such transformation is invalid: https://stackoverflow.com/a/70328102 Should I close this issue as INVALID (and probably op

[Bug c++/108626] New: GCC doesn't combine string literals for const char*const and const char b[]

2023-02-01 Thread marat at slonopotamus dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626 Bug ID: 108626 Summary: GCC doesn't combine string literals for const char*const and const char b[] Product: gcc Version: unknown Status: UNCONFIRMED Severity: