SH-LINUX: CC1 core dumps when compiling libf2c/libI77/wref.c (3.0.x)

NIIBE Yutaka gniibe@m17n.org
Tue Oct 2 02:25:00 GMT 2001


The compiler of 3.0 branch (released 3.0.1 too) dumps core when
compiling libf2c/libI77/wref.c with -O2.

My compiler:
	GNU C version 3.0.2 20011001 (prerelease) (sh-linux)
		compiled by GNU C version 2.95.4 20010902 (Debian prerelease).

When -fno-reorder-blocks flag is added, it works fine.

Here'is the backtrace and smallest input of wref.i.

(gdb) run -fpreprocessed wref.i -musermode -ml -m3 -g -O2 -version
Starting program: /home/gniibe/gniibe/c/gcc-3_0+patch/build/gcc/cc1 -fpreprocessed wref.i -musermode -ml -m3 -g -O2 -version
GNU CPP version 3.0.2 20011001 (prerelease) (cpplib) (SH GNU/Linux with ELF)
GNU C version 3.0.2 20011001 (prerelease) (sh-linux)
	compiled by GNU C version 2.95.4 20010902 (Debian prerelease).
options passed:  -fpreprocessed -musermode -ml -m3 -g -O2
options enabled:  -fdefer-pop -foptimize-sibling-calls -fcse-follow-jumps
 -fcse-skip-blocks -fexpensive-optimizations -fthread-jumps
 -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse -finline
 -fkeep-static-consts -fcaller-saves -freg-struct-return -fdelayed-branch
 -fgcse -frerun-cse-after-loop -frerun-loop-opt
 -fdelete-null-pointer-checks -fschedule-insns2 -fsched-interblock
 -fsched-spec -fbranch-count-reg -freorder-blocks -fcommon -fgnu-linker
 -fregmove -foptimize-register-move -fargument-alias -fstrict-aliasing
 -fident -fpeephole2 -fguess-branch-probability -fmath-errno -m1 -m2 -m3
 -ml -musermode
 __strcpy_small func
Program received signal SIGSEGV, Segmentation fault.
fixup_addr_diff_vecs (first=0x4019d320) at ../../gcc/config/sh/sh.c:2847
(gdb) bt
#0  fixup_addr_diff_vecs (first=0x4019d320) at ../../gcc/config/sh/sh.c:2847
#1  0x81a691b in machine_dependent_reorg (first=0x4019d320)
    at ../../gcc/config/sh/sh.c:3249
#2  0x8079e19 in rest_of_compilation (decl=0x40193680)
    at ../../gcc/toplev.c:3658
#3  0x8056ed3 in c_expand_body (fndecl=0x40193680, nested_p=0)
    at ../../gcc/c-decl.c:6781
#4  0x8056db6 in finish_function (nested=0) at ../../gcc/c-decl.c:6697
#5  0x8049dfc in yyparse_1 () at c-parse.y:324
#6  0x804d002 in yyparse () at ../../gcc/c-lex.c:158
#7  0x80785b6 in compile_file (name=0x8278d24 "wref.i")
    at ../../gcc/toplev.c:2369
#8  0x807bd32 in main (argc=8, argv=0xbffffbb4) at ../../gcc/toplev.c:4990
(gdb) 

--------------------------
typedef struct { unsigned char __arr[2]; } __STRING2_COPY_ARR2 __attribute__ ((packed));
typedef struct { unsigned char __arr[3]; } __STRING2_COPY_ARR3 __attribute__ ((packed));
typedef struct { unsigned char __arr[4]; } __STRING2_COPY_ARR4 __attribute__ ((packed));
typedef struct { unsigned char __arr[5]; } __STRING2_COPY_ARR5 __attribute__ ((packed));
typedef struct { unsigned char __arr[6]; } __STRING2_COPY_ARR6 __attribute__ ((packed));
typedef struct { unsigned char __arr[7]; } __STRING2_COPY_ARR7 __attribute__ ((packed));
typedef struct { unsigned char __arr[8]; } __STRING2_COPY_ARR8 __attribute__ ((packed));

extern __inline char *
__strcpy_small (char *__dest,
                __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3,
                __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5,
                __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7,
                __STRING2_COPY_ARR8 __src8, int __srclen)
{
  union {
    char __c;
    __STRING2_COPY_ARR2 __sca2;
    __STRING2_COPY_ARR3 __sca3;
    __STRING2_COPY_ARR4 __sca4;
    __STRING2_COPY_ARR5 __sca5;
    __STRING2_COPY_ARR6 __sca6;
    __STRING2_COPY_ARR7 __sca7;
    __STRING2_COPY_ARR8 __sca8;
  } *__u = (void *) __dest;
  switch ((unsigned int) __srclen)
    {
    case 1:
      __u->__c = '\0';
      break;
    case 2:
      __extension__ __u->__sca2 = __src2;
      break;
    case 3:
      __extension__ __u->__sca3 = __src3;
      break;
    case 4:
      __extension__ __u->__sca4 = __src4;
      break;
    case 5:
      __extension__ __u->__sca5 = __src5;
      break;
    case 6:
      __extension__ __u->__sca6 = __src6;
      break;
    case 7:
      __extension__ __u->__sca7 = __src7;
      break;
    case 8:
      __extension__ __u->__sca8 = __src8;
      break;
  }
  return __dest;
}

extern void func1(void);

void
func(char *se, double dd)
{
  if (dd)
    func1();
  else
    __strcpy_small (se, 
		    __extension__ ((__STRING2_COPY_ARR2) { { ((__const char *) ("+00"))[0], '\0' } }),
		    __extension__ ((__STRING2_COPY_ARR3) { { ((__const char *) ("+00"))[0], ((__const char *) ("+00"))[1], '\0' } }),
		    __extension__ ((__STRING2_COPY_ARR4) { { ((__const char *) ("+00"))[0], ((__const char *) ("+00"))[1], ((__const char *) ("+00"))[2], '\0' } }),
		    __extension__ ((__STRING2_COPY_ARR5) { { ((__const char *) ("+00"))[0], ((__const char *) ("+00"))[1], ((__const char *) ("+00"))[2], ((__const char *) ("+00"))[3], '\0' } }),
		    __extension__ ((__STRING2_COPY_ARR6) { { ((__const char *) ("+00"))[0], ((__const char *) ("+00"))[1], ((__const char *) ("+00"))[2], ((__const char *) ("+00"))[3], ((__const char *) ("+00"))[4], '\0' } }),
		    __extension__ ((__STRING2_COPY_ARR7) { { ((__const char *) ("+00"))[0], ((__const char *) ("+00"))[1], ((__const char *) ("+00"))[2], ((__const char *) ("+00"))[3], ((__const char *) ("+00"))[4], ((__const char *) ("+00"))[5], '\0' } }),
		    __extension__ ((__STRING2_COPY_ARR8) { { ((__const char *) ("+00"))[0], ((__const char *) ("+00"))[1], ((__const char *) ("+00"))[2], ((__const char *) ("+00"))[3], ((__const char *) ("+00"))[4], ((__const char *) ("+00"))[5], ((__const char *) ("+00"))[6], '\0' } }),
		    strlen ("+00") + 1);
}
--------------------------
-- 



More information about the Gcc-bugs mailing list