https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84478

            Bug ID: 84478
           Summary: [8 Regression] pdftex miscompilation on i386
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

long poolptr;
unsigned char *strpool;
static const char *poolfilearr[] = {
  "mu",
#define A "",
#define B A A A A A A A A A A
#define C B B B B B B B B B B
#define D C C C C C C C C C C
  D C C C C C C C B B B A
 ((void *)0) 
};

__attribute__((noipa)) long
makestring (void)
{
  return 0;
}

__attribute__((noipa))
int
loadpoolstrings (long spare_size)
{
  const char *s;
  long g = 0;
  int i = 0, j = 0;
  while ((s = poolfilearr[j++]))
    {
      int l = __builtin_strlen (s);
      i += l;
      if (i >= spare_size) return 0;
      while (l-- > 0) strpool[poolptr++] = *s++;
      g = makestring ();
    }
  return g;
}

int
main ()
{
  poolptr = 0;
  strpool = __builtin_malloc (1000);
  asm volatile ("" : : : "memory");
  volatile int r = loadpoolstrings (1000);
  __builtin_free (strpool);
  return 0;
}

is miscompiled with -O2 -m32 starting with r256477.

Reply via email to