https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89996
Bug ID: 89996 Summary: [avr] ICE in expand_expr_real_2 with -O3 Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: gandalf at winds dot org Target Milestone: --- The following fails with GCC 8.2 and 8.3 on AVR. The below output is from 8.3: # avr-gcc -v -O3 -mmcu=atmega1284p -c test2.c -o test2.o Using built-in specs. Reading specs from /usr/local/avr/lib/gcc/avr/8.3.0/device-specs/specs-atmega1284p COLLECT_GCC=avr-gcc Target: avr Configured with: ../configure --target=avr --prefix=/usr/local/avr --disable-nls --enable-languages=c --disable-bootstrap --disable-libssp Thread model: single gcc version 8.3.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-O3' '-c' '-o' 'test2.o' '-specs=device-specs/specs-atmega1284p' '-mmcu=avr51' /usr/local/avr/libexec/gcc/avr/8.3.0/cc1 -quiet -v -imultilib avr51 -D__AVR_ATmega1284P__ -D__AVR_DEVICE_NAME__=atmega1284p test2.c -mn-flash=2 -mno-skip-bug -quiet -dumpbase test2.c -mmcu=avr51 -auxbase-strip test2.o -O3 -version -o /tmp/ccYds885.s GNU C17 (GCC) version 8.3.0 (avr) compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/avr/lib/gcc/avr/8.3.0/../../../../avr/sys-include" #include "..." search starts here: #include <...> search starts here: /usr/local/avr/lib/gcc/avr/8.3.0/include /usr/local/avr/lib/gcc/avr/8.3.0/include-fixed /usr/local/avr/lib/gcc/avr/8.3.0/../../../../avr/include End of search list. GNU C17 (GCC) version 8.3.0 (avr) compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: e17ca263eb8b0996b4ab7dcf63f27ece during RTL pass: expand test2.c: In function 'send_document.isra.0.constprop': test2.c:33:11: internal compiler error: in expand_expr_real_2, at expr.c:8573 0x51269b expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc/expr.c:8573 0x70e9a0 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.c:9968 0x71c001 expand_expr ../../gcc/expr.h:280 0x71c001 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc/expr.c:8575 0x70e9a0 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.c:9968 0x6195f1 expand_normal ../../gcc/expr.h:286 0x6195f1 precompute_register_parameters ../../gcc/calls.c:989 0x6195f1 expand_call(tree_node*, rtx_def*, int) ../../gcc/calls.c:4127 0x70e2e6 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.c:11050 0x71734b store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*) ../../gcc/expr.c:5651 0x718189 expand_assignment(tree_node*, tree_node*, bool) ../../gcc/expr.c:5419 0x718189 expand_assignment(tree_node*, tree_node*, bool) ../../gcc/expr.c:4954 0x626e38 expand_call_stmt ../../gcc/cfgexpand.c:2702 0x626e38 expand_gimple_stmt_1 ../../gcc/cfgexpand.c:3638 0x626e38 expand_gimple_stmt ../../gcc/cfgexpand.c:3804 0x628c4f expand_gimple_basic_block ../../gcc/cfgexpand.c:5833 0x62dcc6 execute ../../gcc/cfgexpand.c:6439 Please submit a full bug report. Code to reproduce: extern char *strrchr(const char *, int) __attribute__((__pure__)); extern int strcasecmp_P(const char *, const char *) __attribute__((__pure__)); static const struct { char ext[5]; const char __flash *desc; _Bool subst; } __flash mime_types[]={ {"txt", ((const char __flash []){("text/plain; charset=utf-8")}), 1}, {"html", ((const char __flash []){("text/html; charset=utf-8")}), 1}, {"htm", ((const char __flash []){("text/html; charset=utf-8")}), 1}, }; struct http { char uri[128]; _Bool sendfile_subst; }; typedef struct { unsigned char user[sizeof(struct http)]; } DESC; static void send_document(DESC *d, short err, const char __flash *err_string, const char *file, _Bool conn_close) { struct http *hd=(void *)d->user; const char *ext; unsigned char i; _Bool subst=0; if((ext=strrchr(file, '.'))) { for(i=0;i < (int)(sizeof(mime_types)/sizeof(mime_types[0]));i++) if(!strcasecmp_P(ext, mime_types[i].ext)) { subst=mime_types[i].subst; break; } } hd->sendfile_subst=subst; } static void http_do_uri_request(DESC *d) { struct http *hd=(void *)d->user; char *uri=hd->uri; if(*uri != '/') { send_document(d, 400, ({ static const char __flash _str[]=("Bad Request"); _str; }), "error/400.html", 1); return; } send_document(d, 403, ({ static const char __flash _str[]=("Forbidden"); _str; }), "error/403.html", 0); } int main() { http_do_uri_request((void *)123); } Notes: The ICE does not happen if flag -O2 is used instead of -O3. Also no ICE happens if the __flash keyword is removed from before "mime_types[]={". Also no ICE happens if the number of entries in mime_types[] is less than 3.