https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117817
Bug ID: 117817 Summary: Compile error when taking address of temporary array in sizeof operator Product: gcc Version: 13.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: odion at efficios dot com Target Milestone: --- The following program compiles fine with all versions of GCC except for version 13. a-bug.ii: # 0 "bug.cpp" # 0 "<built-in>" # 0 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 # 0 "<command-line>" 2 # 1 "bug.cpp" constexpr int c = 1; struct e { int *b; }; struct { long d; } a{sizeof e{(int[]){c}}}; int main() {} error: bug.cpp:7:21: error: taking address of temporary array 7 | } a{sizeof e{(int[]){c}}}; | command: g++ a-bug.ii Toolchain: Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.3.0 (GCC) System: Guix System -- What I find weird is that an error is reported for taking the address of a temporary array in a sizeof() operator. What is even weirder is that if you change the expression `constexpr int c = 1;' to `#define c 1', then there is no error. However, changing it to `enum { c };' does trigger the same error.