[Bug rtl-optimization/69691] New: [6 Regression] wrong code at -O2 on x86_64-linux-gnu
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Feb 5 13:26:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69691
Bug ID: 69691
Summary: [6 Regression] wrong code at -O2 on x86_64-linux-gnu
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
$ xgcc -O2 zz.c; ./a.out
Aborted (core dumped)
extern int tolower (int) __attribute__ ((leaf));
char *USHyphens[] = { ".ach4", 0 };
#define LCNT (26 + 1 + 4)
#define SEPCNT 10
typedef struct sHyphenNode
{
char sepcnts[SEPCNT];
struct sHyphenNode *Daughters[LCNT];
} THyphenNode, *PHyphenNode;
static PHyphenNode HyphenRoot = 0;
static int
GetIndex (char ch)
{
if (ch == 0)
__builtin_abort ();
if ((tolower (ch) >= 'a' - 1) && (tolower (ch) <= 'z'))
return (tolower (ch) - ('a' - 1));
else if (ch == '.')
return 0;
else
{
__builtin_printf ("unallowed character %d\n", ch);
return -1;
}
}
static void
InitHyphenNode (PHyphenNode Node)
{
int z;
for (z = 0; z < LCNT; Node->Daughters[z++] = 0);
for (z = 0; z < SEPCNT; Node->sepcnts[z++] = 0);
}
void
BuildTree (char **Patterns)
{
char **run, ch, *pos, sing[500], *rrun;
char RunCnts[SEPCNT];
int z, l, rc, index;
PHyphenNode Lauf;
HyphenRoot = (PHyphenNode) __builtin_malloc (sizeof (THyphenNode));
InitHyphenNode (HyphenRoot);
for (run = Patterns; *run != 0; run++)
{
__builtin_strcpy (sing, *run);
rrun = sing;
do
{
pos = __builtin_strchr (rrun, ' ');
if (pos)
*pos = '\0';
l = __builtin_strlen (rrun);
rc = 0;
Lauf = HyphenRoot;
for (z = 0; z < SEPCNT; RunCnts[z++] = 0);
for (z = 0; z < l; z++)
{
ch = rrun[z];
if ((ch >= '0') && (ch <= '9'))
RunCnts[rc] = ch - '0';
else
{
index = GetIndex (ch);
if (!Lauf->Daughters[index])
{
Lauf->Daughters[index] =
(PHyphenNode) __builtin_malloc (sizeof (THyphenNode));
InitHyphenNode (Lauf->Daughters[index]);
}
Lauf = Lauf->Daughters[index];
rc++;
}
}
__builtin_memcpy (Lauf->sepcnts, RunCnts, SEPCNT);
if (pos)
rrun = pos + 1;
}
while (pos);
}
}
void
DoHyphens (char *word)
{
char Field[300];
char Res[300];
int z, z2, z3, l;
PHyphenNode Lauf;
l = __builtin_strlen (word);
*Field = 'a' - 1;
for (z = 0; z < l; z++)
{
Field[z + 1] = tolower ((unsigned int) word[z]);
if (GetIndex (Field[z + 1]) <= 0)
return;
}
Field[l + 1] = 'a' - 1;
l += 2;
for (z = 0; z <= l + 1; Res[z++] = 0);
if (!HyphenRoot)
return;
for (z = 0; z < l; z++)
{
Lauf = HyphenRoot;
for (z2 = z; z2 < l; z2++)
{
Lauf = Lauf->Daughters[GetIndex (Field[z2])];
if (!Lauf)
break;
for (z3 = 0; z3 <= z2 - z + 2; z3++)
if (Lauf->sepcnts[z3] > Res[z + z3])
Res[z + z3] = Lauf->sepcnts[z3];
}
}
for (z = 3; z < l - 2; z++)
if ((Res[z] & 1) == 1)
asm ("");
}
int
main ()
{
BuildTree (USHyphens);
DoHyphens ("aaaaa");
}
More information about the Gcc-bugs
mailing list