This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: target/10194: [3.2 regression] [arm] gcc optimization error with -O2, affecting bison - Testcase found
- From: "Stan Katz" <Stan dot Katz at ctc-control dot com>
- To: <ehrhardt at mathematik dot uni-ulm dot de>,<gcc-bugs at gcc dot gnu dot org>,<gcc-prs at gcc dot gnu dot org>,<gcc-gnats at gcc dot gnu dot org>
- Date: Mon, 7 Jun 2004 14:36:26 -0400
- Subject: Re: target/10194: [3.2 regression] [arm] gcc optimization error with -O2, affecting bison - Testcase found
I have also recently run into this error, however it was not in one of the GNU packages and I managed to develop a small testcase that does cause the error (included within the email below), I am sending this, even though the bug is marked as closed, since it does provide a simple testcase for the problem.
the command line with compiler flags is
arm-elf-gcc -c -gdwarf-23 -O2 -mcpu=arm7tdmi -Wall -c -o testarm.o ../src/testarm.c
If you set the ARMFAIL macro to zero then there is no error, a non zero value generates the error
../src/testarm.c: In function `filename':
../src/testarm.c:46: Internal compiler error in arm_rtx_costs, at config/arm/arm.c:2810
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
The problem seems to be the test
if ((entry % 100) / 10)
Which, although ugly, is valid C. There is a simple work around for my problem, so I will not have to upgrade to a later compiler (and redo all my system regression testing). Not surprisingly, considering the error message and the file referenced, this doesn't happen with the sh-elf build of this version of the compiler.
Error 10194 Testcase:
// Test file for ARM compiler error
#define ARMFAIL 1 // generated compiler failure below when set to 1
/*
../src/testarm.c: In function `filename':
../src/testarm.c:46: Internal compiler error in arm_rtx_costs, at config/arm/arm.c:2810
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
*/
void filename(unsigned char *shortname, unsigned int entry, int i)
{
/* Name suffice is between 000 and 999, calculate this short file
name's numeric component. */
entry = entry % 1000;
if (entry / 100)
{
/* Build short name of the format xxxx~NNN.ext. */
if (i>4) i = 4;
shortname[i++] = '~';
shortname[i++] = '0' + (entry / 100);
shortname[i++] = '0' + ((entry % 100) / 10);
shortname[i++] = '0'+ (entry % 10);
}
#if ARMFAIL
else if ((entry % 100) / 10)
#else // ARMFAIL = 0
else if (entry > 10)
#endif // ARMFAIL
{
/* Build short name of the format xxxxx~NN.ext. */
if (i>5) i = 5;
shortname[i++] = '~';
shortname[i++] = '0' + ((entry % 100) / 10);
shortname[i++] = '0'+ (entry % 10);
}
else
{
/* Build short name of the format xxxxxx~N.ext. */
if (i>6) i = 6;
shortname[i++] = '~';
if ((entry % 10) == 0) entry++;
shortname[i++] = '0'+ (entry % 10);
}
/* Set end of short string to NULL. */
shortname[11] = 0;
}