[PATCH] D124038: [clang] Prevent folding of non-const compound expr

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 10 13:50:52 PDT 2022


serge-sans-paille added a comment.

In D124038#3504371 <https://reviews.llvm.org/D124038#3504371>, @efriedma wrote:

> I think you're looking at old documentation?  Here's what the current page (https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html) has to say:

Indeed! I was looking at my local Info Page. thanks for the extra pointer.

>> As an optimization, G++ sometimes gives array compound literals longer lifetimes: when the array either appears outside a function or has a const-qualified type. If foo and its initializer had elements of type char *const rather than char *, or if foo were a global variable, the array would have static storage duration. But it is probably safest just to avoid the use of array compound literals in C++ code.

I can quote that part instead. I don't think this invalidates the actual code, right? At least with that commit the observable behavior gets closer to GCC, and it fixes https://github.com/llvm/llvm-project/issues/39324


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124038/new/

https://reviews.llvm.org/D124038



More information about the cfe-commits mailing list