Compiling the following code with -O2 causes an ICE (verified on both 
i686-pc-cygwin and arm-none-
elf):

struct mad_bitptr {
  unsigned char const *byte;
};

struct mad_stream {
  struct mad_bitptr ptr;
};

struct channel {
  unsigned short part2_3_length;
};

struct granule {
  struct channel ch[2];
};

struct sideinfo {
  struct granule gr[2];
};

static
void III_sideinfo(struct mad_bitptr *ptr, struct sideinfo *si)
{
  unsigned int ngr, gr, ch;
  unsigned int nch;

  for (gr = 0; gr < ngr; ++gr) {
    struct granule *granule = &si->gr[gr];

    for (ch = 0; ch < nch; ++ch) {
      struct channel *channel = &granule->ch[ch];

      channel->part2_3_length = 1;
    }
  }
}

void mad_layer_III(struct mad_stream *stream)
{
  struct sideinfo si;

  III_sideinfo(&stream->ptr, &si);
}

This happens in the mainline, and appears to be the result of one of the 
patches applied 2005-05-17, 
as it doesn't happen in a snapshot from the previous day.

A segfault is occurring when the function is_gimple_val (from tree-gimple.c) 
passes a NULL value to 
is_gimple_reg_type().

-- 
           Summary: ICE on code with nested loops
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jconner at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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

Reply via email to