At optimization levels -Os, -O1, and -O2, the attached program generates incorrect loop code. It appears that when optimizing, the loop termination is checking array end address versus current pointer. The array end address contains all address bits while the current pointer is just the lower (16?) bits.
m32c-elf-gcc -O1 -mcpu=m32cm -msim m1.c && m32c-elf-run a.out NULL pointer dereference Attaching test program. -- Summary: invalid loop generation Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: joel at gcc dot gnu dot org GCC target triplet: m32c-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37665