This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/4949: <synopsis of the problem (one line)> switch + 5 cases + -O2 or no O crashes gcc-3.0.2

[Get raw message]

>Number:         4949
>Category:       c
>Synopsis:       switch + 5 cases + -O2 or no O crashes gcc-3.0.2
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 26 11:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Dennis Altrogge
>Release:        3.0.2
>Organization:
Nortel Networks
>Environment:
System: SunOS farside 5.6 Generic_105181-25 sun4m sparc SUNW,SPARCstation-20
Architecture: sun4

	
host: sparc-sun-solaris2.6
build: sparc-sun-solaris2.6
target: m68k-unknown-elf
configured with: ../gcc-3.0.2/configure --target=m68k-elf --with-newlib --prefix=/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf
>Description:
	
The enclosed code crashes gcc-3.0.2 with optimization levels
-O2 or without O but not with -O.
Some lines that make the function legal are #ifed out but the
crash occurs with or without them.
Changing any of the case statements seems to fix the problem.
I haven't tried the problem on previous versions of gcc yet.

######## error message follows ########### 


gmake -f Makefile.gnu badcode.o
/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/bin/m68k-elf-gcc -c -g   -Wall -v -save-temps  \
        -m5200 -Wa,-register-prefix-optional badcode.c
Reading specs from /engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/specs
Configured with: ../gcc-3.0.2/configure --target=m68k-elf --with-newlib --prefix=/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf
Thread model: single
gcc version 3.0.2
 /engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/cpp0 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=2 -Dmc68000 -D__embedded__ -D__mc68000__ -D__embedded__ -D__mc68000 -Asystem=embedded -Amachine=mc68000 -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Wall -Dmcf5200 -D__mcf5200__ -D__mcf5200 badcode.c badcode.i
GNU CPP version 3.0.2 (cpplib) (68k, MIT syntax)
ignoring nonexistent directory "/engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/m68k-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/include
 /engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/m68k-elf/include
End of search list.
 /engwest/agt_tools/compilers/gcc/3.0.2-sol26-m68k-elf/lib/gcc-lib/m68k-elf/3.0.2/cc1 -fpreprocessed badcode.i -quiet -dumpbase badcode.c -m5200 -g -Wall -version -o badcode.s
GNU CPP version 3.0.2 (cpplib) (68k, MIT syntax)
GNU C version 3.0.2 (m68k-elf)
        compiled by GNU C version 2.95.2 19991024 (release).
badcode.c: In function `c_SrecProcFile':
badcode.c:51: Insn does not satisfy its constraints:
(insn 85 19 45 (set (reg:QI 8 %a0)
        (mem/f:QI (plus:SI (reg/f:SI 14 %a6)
                (const_int -1 [0xffffffff])) 0)) 37 {*m68k.md:1060} (nil)
    (nil))
badcode.c:51: Internal compiler error in final_scan_insn, at final.c:2876
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
gmake: *** [badcode.o] Error 1

>How-To-Repeat:
	
########### this is the badcode.c  file ###################
############ crashes with optimization -O2 or not O but NOT with -O #####

/*=======================================================================
srec.c
srec.c: In function `c_SrecProcFile':
srec.c:53: Insn does not satisfy its constraints:
(insn 85 19 45 (set (reg:QI 8 %a0)
        (mem/f:QI (plus:SI (reg/f:SI 14 %a6)
                (const_int -1 [0xffffffff])) 0)) 37 {*m68k.md:1060} (nil)
    (nil))
srec.c:53: Internal compiler error in final_scan_insn, at final.c:2876
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
gmake: *** [srec.o] Error 1


* with gcc-core-3.0.2 for m68k-elf binutils-2.11.2 and newlib-1.9.0
*========================================================================
*/
#if 0	/* this is not necessary to cause the crash */
signed   char       c_GetDlChar( void );
#endif

signed   char  c_SrecProcFile(
                              )
{
   signed   char     c_SrecType;

   while( 1 )  /* forever */
   {
#if 0	/* this is not necessary to cause the crash */
      if( ( c_SrecType = c_GetDlChar() ) < 0 )
         return   c_SrecType;
#endif
      switch( c_SrecType )
      {
/* removing any of these cases fixes it */
      case  '0':
         break;

      case  '3':
         break;

      case  '5':
         break;

      case  '8':
      case  '9':
         return   0;
      }
   }
}

################## this is the badcode.i file ######################

# 23 "badcode.c"
signed char c_SrecProcFile(
                              )
{
   signed char c_SrecType;

   while( 1 )
   {




      switch( c_SrecType )
      {

      case '0':
         break;

      case '3':
         break;

      case '5':
         break;

      case '8':
      case '9':
         return 0;
      }
   }
}

############## this is the badcode.s file #########################

	.file	"badcode.i"
	.stabs	"/bnw/home/altrogge/tiger/",100,0,0,.Ltext0
	.stabs	"badcode.i",100,0,0,.Ltext0
	.text
.Ltext0:
	.stabs	"gcc2_compiled.",60,0,0,0
	.stabs	"int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0
	.stabs	"char:t(0,2)=r(0,2);0;127;",128,0,0,0
	.stabs	"long int:t(0,3)=r(0,3);-2147483648;2147483647;",128,0,0,0
	.stabs	"unsigned int:t(0,4)=r(0,4);0000000000000;0037777777777;",128,0,0,0
	.stabs	"long unsigned int:t(0,5)=r(0,5);0000000000000;0037777777777;",128,0,0,0
	.stabs	"long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;",128,0,0,0
	.stabs	"long long unsigned int:t(0,7)=@s64;r(0,7);0000000000000;01777777777777777777777;",128,0,0,0
	.stabs	"short int:t(0,8)=@s16;r(0,8);-32768;32767;",128,0,0,0
	.stabs	"short unsigned int:t(0,9)=@s16;r(0,9);0;65535;",128,0,0,0
	.stabs	"signed char:t(0,10)=@s8;r(0,10);-128;127;",128,0,0,0
	.stabs	"unsigned char:t(0,11)=@s8;r(0,11);0;255;",128,0,0,0
	.stabs	"float:t(0,12)=r(0,1);4;0;",128,0,0,0
	.stabs	"double:t(0,13)=r(0,1);8;0;",128,0,0,0
	.stabs	"long double:t(0,14)=r(0,1);12;0;",128,0,0,0
	.stabs	"complex int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;",128,0,0,0
	.stabs	"complex float:t(0,16)=r(0,16);8;0;",128,0,0,0
	.stabs	"complex double:t(0,17)=r(0,17);16;0;",128,0,0,0
	.stabs	"complex long double:t(0,18)=r(0,18);24;0;",128,0,0,0
	.stabs	"__builtin_va_list:t(0,19)=*(0,20)=(0,20)",128,0,0,0
	.stabs	"_Bool:t(0,21)=@s8;-16;",128,0,0,0
	.stabs	"c_SrecProcFile:F(0,10)",36,0,25,c_SrecProcFile
	.globl	c_SrecProcFile
	.type	c_SrecProcFile,@function
c_SrecProcFile:
	.stabs	"badcode.c",132,0,0,.Ltext1
.Ltext1:
	.stabn 68,0,25,.LM1-c_SrecProcFile
.LM1:
	link.w %a6,#-8
.LBB2:
	.stabn 68,0,26,.LM2-c_SrecProcFile
.LM2:
	nop
.L4:
	.stabn 68,0,34,.LM3-c_SrecProcFile
.LM3:
>Fix:
compile works with -O optimization
	
>Release-Note:
>Audit-Trail:
>Unformatted:
 Severity:	<[ non-critical | serious | critical ] (one line)> serious
 icd-on-legal-code


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]