https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98132
Bug ID: 98132 Summary: ‘target_mem_ref’ not supported by expression internal error Product: gcc Version: 6.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: thutt at vmware dot com Target Milestone: --- #if 0 The program below, compiled with: x86_64-vmk-linux-gnu-gcc (GCC) 6.4.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. fails with the following internal gcc error and an incorrect warning: #‘target_mem_ref’ not supported by expression#’./main.c: In function ‘main’: ./main.c:15:12: warning: is used uninitialized in this function [-Wuninitialized] return (*(uint16*)&ote.field[i] >> i) & 0x1ff; ^~~~~~~~~~~~~~~~~~~~~~~ ./main.c:19:1: note: ‘ote’ was declared here f1(t0_t ote) ^~ The compiler used was built in-house. The command line is: CC=<path to gcc> ${CC} \ -nostdinc \ -O2 \ -Wuninitialized \ -o ./main.o \ -c ./main.c #endif typedef unsigned char uint8; typedef unsigned short int uint16; typedef struct t0_t { uint8 field[5]; } t0_t; extern t0_t ote; static unsigned f0(t0_t ote, unsigned i) { return (*(uint16*)&ote.field[i] >> i) & 0x1ff; } static unsigned f1(t0_t ote) { int i; for (i = 0; i < 4; i++) { unsigned j = f0(ote, i); if (j == 1) { return 1; } } return 0; } int main(int argc, char **argv) { return f1(ote); }