This bug happens only when both -fomit-frame-pointer and -mdalign are specified. If only one of them is not specified, the compilation works. Don't work: sh-elf-gcc -v -save-temps -fomit-frame-pointer -ml -mdalign -c GccShBug.c Work: sh-elf-gcc -v -save-temps -fomit-frame-pointer -ml -c GccShBug.c Work: sh-elf-gcc -v -save-temps -ml -mdalign -c GccShBug.c Work: sh-elf-gcc -v -save-temps -ml -c GccShBug.c GCC output: $ sh-elf-gcc -v -save-temps -fomit-frame-pointer -ml -mdalign -c GccShBug.c Reading specs from /usr/local/lib/gcc-lib/sh-elf/3.2/specs Configured with: ../gcc-3.2/configure --target=sh-elf --prefix=/usr/local --with out-headers --with-newlib --enable-languages=c : (reconfigured) ../gcc-3.2/confi gure --target=sh-elf --prefix=/usr/local --without-headers --with-newlib --enabl e-languages=c,c++ Thread model: single gcc version 3.2 /usr/local/lib/gcc-lib/sh-elf/3.2/cpp0.exe -lang-c -v -D__GNUC__=3 -D__GNUC_MIN OR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__sh__ -D__ELF__ -D__sh __ -D__ELF__ -Acpu=sh -Amachine=sh -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D__sh1__ -D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D__LITTLE_ENDIAN__ GccShBu g.c GccShBug.i GNU CPP version 3.2 (cpplib) (Hitachi SH) #include "..." search starts here: #include <...> search starts here: /usr/local/lib/gcc-lib/sh-elf/3.2/include /usr/local/sh-elf/sys-include /usr/local/sh-elf/include End of search list. /usr/local/lib/gcc-lib/sh-elf/3.2/cc1.exe -fpreprocessed GccShBug.i -quiet -dum pbase GccShBug.c -ml -mdalign -version -fomit-frame-pointer -o GccShBug.s GNU CPP version 3.2 (cpplib) (Hitachi SH) GNU C version 3.2 (sh-elf) compiled by GNU C version 2.95.3-5 (cygwin special). GccShBug.c: In function `divCeil': GccShBug.c:11: Internal compiler error in output_stack_adjust, at config/sh/sh.c :4195 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. Release: GCC 3.2 Environment: Cygwin or GNUSH 0302 How-To-Repeat: int divCeil(int a, int b) { int c; if (a>0) { if (b>0) c=a+b-1; else c=a; } else { if (b>0) c=a; else c=a+b+1; } return c/b; }
Fix: Simple: don't use at the same time -fomit-frame-pointer and -mdalign.
From: Dara Hazeghi <dhazeghi@yahoo.com> To: gcc-gnats@gcc.gnu.org, mathieu@thenesis.com Cc: Subject: Re: target/10589: For Hitachi SH target, GCC craches when both -fomit-frame-pointer and -mdalign options are specified Date: Sat, 10 May 2003 12:38:21 -0700 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- trail&database=gcc&pr=10589 Hello, this is just to confirm that this bug exists on 3.3 branch and mainline as well. Dara
See Dara's comment.
Here is an even smaller testcase. int foo (int a, int b) { return a / b; }
The testcase fails neither in gcc-3.0.2 as patched here in 2001, nor in gcc-2.95 as supplied by Montavista in 2001, so is it fair to say this is a regression?
I've prepared a patch to add a testcase for this PR to the testsuite; see http://www.kegel.com/crosstool/current/patches/gcc-3.3.1/pr10589-1-test.patch I'll submit it to gcc-patches in a couple days if nobody squawks.
The testcase fails with 3.4.6, but doesn't fail with 4.0 and later compilers. So I'd like to close this PR as WONTFIX because 3.4 was frozen.