https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91925
Bug ID: 91925
Summary: -fpack-struct causes a decltype with template to ICE
Product: gcc
Version: 9.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jan at ypmania dot nl
Target Milestone: ---
Created attachment 46959
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46959&action=edit
Minimal reproducer testcase
When compiling the given test case (which uses decltype on an expression that
needs template argument inference) with "-fpack-struct", gcc produces an
internal compiler error (segmentation fault).
$ gcc -fpack-struct test.cpp -o test.o
test.cpp:21:32: internal compiler error: Segmentation fault
21 | auto_var(pinTX, PinPD1(usart0));
| ^
test.cpp:17:39: note: in definition of macro ‘auto_var’
17 | #define auto_var(name, expr) decltype(expr) name = expr
Removing pack-struct makes the code compile fine, as does uncommenting the
alternative declaration on line 22 (which does not use decltype).
This is on 9.2.0 (arch linux). Using compiler explorer shows that trunk, 9.2,
9.1 have the bug, while 8.3.0 compiled this fine (with -fpack-struct).
The context is AVR embedded development, where it is common to use
-fpack-struct (and not use any standard library).