[clang] [Clang][Sema] Reject array prvalue operands (PR #140702)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue May 20 09:16:56 PDT 2025


AaronBallman wrote:

> > That probably should continue to work -- we accept it today and so does GCC
> 
> GCC started accepting it from version 14, likely when fixing https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94264 (it is mentioned in [#54016 (comment)](https://github.com/llvm/llvm-project/issues/54016#issuecomment-1752262953)), but it also started accepting `IA{ 1, 2, 3 } + 0`, which is clearly wrong https://godbolt.org/z/r7Yc3o1qd @pinskia @jicama
> 
> I think, if someone wants 100% C compatibility, then they should make compound literals lvalues. If compound literals are prvalues in C++ extension, then they should be treated like other array prvalues

Ugh, I was backwards again. They're prvalues in C++ already, not lvalues as in C, so yes, it should be rejected in C++ with your changes. Sorry for the confusion!

https://github.com/llvm/llvm-project/pull/140702


More information about the cfe-commits mailing list