* Optimization bug in current GCC CVS mainline
@ 2001-05-06 4:35 Andreas Jaeger
0 siblings, 0 replies; only message in thread
From: Andreas Jaeger @ 2001-05-06 4:35 UTC (permalink / raw)
To: libc-alpha; +Cc: gcc-bugs, Jan Hubicka
[-- Attachment #1: Type: text/plain, Size: 3324 bytes --]
The following small program fails with current gcc 3.1 from CVS if the
i486 specific <bits/string.h> header is used with:
$ /opt/gcc-3.1-devel/bin/gcc -Wall strpbrk-test.c -O3 -g -march=pentiumpro -mcpu=i686;./a.out
strpbrk flunked test 10
I'm appending some more information and the preprocessed sources.
Removing the first or last strcpy problem leads to a working program,
therefore it looks like gcc optimizes the second strcpy away :-(.
Any help is appreciated,
Andreas
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define _GNU_SOURCE
#define __USE_STRING_INLINES 1
#include <stdio.h>
#include <string.h>
char one[50];
const char *it = "<UNSET>"; /* Routine name for message routines. */
size_t errors = 0;
static void
check (int thing, int number)
{
if (!thing)
{
printf("%s flunked test %d\n", it, number);
++errors;
}
}
static void
test_strpbrk (void)
{
it = "strpbrk";
(void) strcpy(one, "abcabdea");
(void) strcpy(one, "");
check(strpbrk(one, "bc") == NULL, 10); /* Empty string. */
(void) strcpy(one, "");
}
int
main (void)
{
test_strpbrk ();
return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ /opt/gcc-3.1-devel/bin/gcc -Wall strpbrk-test.c -O3 -g -march=pentiumpro -mcpu=i686 -save-temps -v
Reading specs from /opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: /cvs/gcc/configure --prefix=/opt/gcc-3.1-devel --enable-shared --enable-threads=posix --with-gnu-as --with-gnu-ld --disable-nls --with-system-zlib --enable-languages=c,objc,c++,f77,java
Thread model: posix
gcc version 3.1 20010505 (experimental)
/opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1/cpp0 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__tune_i686__ -D__tune_pentiumpro__ strpbrk-test.c strpbrk-test.i
GNU CPP version 3.1 20010505 (experimental) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
/opt/gcc-3.1-devel/i686-pc-linux-gnu/include
/usr/include
End of search list.
/opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1 -fpreprocessed strpbrk-test.i -quiet -dumpbase strpbrk-test.c -march=pentiumpro -mcpu=i686 -g -O3 -Wall -version -o strpbrk-test.s
GNU CPP version 3.1 20010505 (experimental) (cpplib) (i386 Linux/ELF)
GNU C version 3.1 20010505 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 3.1 20010505 (experimental).
as -V -Qy -o strpbrk-test.o strpbrk-test.s
GNU assembler version 2.11.90 (i686-pc-linux-gnu) using BFD version 2.11.90
/opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtbegin.o -L/opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1 -L/opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../.. strpbrk-test.o -lgcc -lc -lgcc /opt/gcc-3.1-devel/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtend.o /usr/lib/crtn.o
[-- Attachment #2: strpbrk-test.i.gz --]
[-- Type: application/x-gzip, Size: 10194 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-05-06 4:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-06 4:35 Optimization bug in current GCC CVS mainline Andreas Jaeger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).