https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69037
Bug ID: 69037 Summary: arrays of constants as function arguments misinterpreted Product: gcc Version: 5.3.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: arigo at tunes dot org Target Milestone: --- The following occurs in `gcc_5_branch` but not in the 5.3.0 release tag. The C front-end misinterprets arrays of constants which are passed as function arguments. Example: typedef const int array_t[3]; int allocate_with_allocator(array_t ar) { int a = ar[0]; int b = ar[1]; return a + b; } This produces two warnings on the lines defining `int a` and `int b` ("initialization makes integer from pointer without a cast") and outputs bogus code (tested with `gcc -S -O2` on x86-64): leal 12(%rdi,%rdi), %eax ret Note that it works fine if we remove "const" from the example above. In that case, or on previous versions of gcc (up to and including 5.3.0), the code is compiled without warning to: movl 4(%rdi), %eax addl (%rdi), %eax ret Fwiw, this error is consistent with the argument "ar" being mistakenly considered to be of type "array_t *" instead of "array_t".