Inconsistent deduplication of string literals #60476
Labels
llvm:optimizations
question
A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Given the following code
and compiling it with
-O1
and higher, I would expect either one or three literals in object file. One in case this falls under "String literals, and compound literals with const-qualified types, need not designate distinct objects." from the standard, and three in case it doesn't. But what in fact clang 15.0.0 produces is two literals:So, clang thinks it is safe to merge
a
+c
variables, but doesn't think it is safe to mergeb
to the same address. Is it misbehaving optimization or I am misunderstanding something?Also, there's currently a discussion on GCC bugtracker going on that tries to decide whether merging of
a
+c
is valid at all or it violates the standard. GCC doesn't merge anything in given testcase and produces three literals in output.Godbolt playground: https://godbolt.org/z/Td67dfrEE
The text was updated successfully, but these errors were encountered: