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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue May 20 08:51:58 PDT 2025


AaronBallman wrote:

> However, it "breaks" compound literal C++ extension:
> 
> ```
> $ build/bin/clang++ -fsyntax-only test.cxx 
> test.cxx:12:2: error: array prvalue is not permitted
>    12 |         *((int []){ 1, 2, 3});
>       |         ^~~~~~~~~~~~~~~~~~~~~
> test.cxx:13:23: error: array prvalue is not permitted
>    13 |         ((int []){ 1, 2, 3}) + 0;
>       |         ~~~~~~~~~~~~~~~~~~~~ ^
> 2 errors generated.
> ```

That probably should continue to work -- we accept it today and so does GCC. It's a bit of an oddity, to be sure. But I don't see why it should be rejected either.


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


More information about the cfe-commits mailing list