GCC (156804, x86_64-unknown-linux-gnu) generates an ICE in compiling the
following code. 

typedef __builtin_va_list va_list;


struct __attribute__((aligned (4))) S238 { struct{}a[24]; short b; } ; 
struct __attribute__((aligned (4))) S238 a238[5]; 

extern int fails;

void foo (int z, ...) { 
  struct __attribute__((aligned (4))) S238 arg, *p; 
  va_list ap; 
  int i; 

    __builtin_va_start(ap,z);
    for (i = 0; i < 5; ++i) 
    { 
      p = ((void *)0); 
      p = &a238[2]; 
      arg = __builtin_va_arg(ap,struct __attribute__((aligned (4))) S238); 
      if (p->b != arg.b) ++fails; 
    }
     __builtin_va_end(ap); 
}

~/work/install-x86/bin/gcc t001_y.c -O2 -w
t001_y.c: In function 'foo':
t001_y.c:24:1: internal compiler error: Floating point exception
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

The error happens in tree-sra.c:1445, where el_size is 0
offset = offset % el_size;

It is likely caused by the following change:

   if (lacc && racc
       && (sra_mode == SRA_MODE_EARLY_INTRA || sra_mode == SRA_MODE_INTRA)
       && !lacc->grp_unscalarizable_region
@@ -1288,7 +1398,12 @@
              if (!tr_size || !host_integerp (tr_size, 1))
                continue;
              size = tree_low_cst (tr_size, 1);
-             if (pos > offset || (pos + size) <= offset)
+             if (size == 0)
+               {
+                 if (pos != offset)
+                   continue;
+               }
+             else if (pos > offset || (pos + size) <= offset)
                continue;


Here, size = 0, pos = 0, offset = 0. So "continue" is executed in past,
but not with this patch, which causes the ICE later. I am not sure what
is intention of the patch, so would leave others to fix it.


-- 
           Summary: ICE in tree-sra.c  with floating point exception
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bmei at broadcom dot com
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43098

Reply via email to