public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/41946] New: tree-vrp eliminates needed conditioanl
@ 2009-11-05 2:41 kevfox at cisco dot com
2009-11-05 10:07 ` [Bug c/41946] " rguenth at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: kevfox at cisco dot com @ 2009-11-05 2:41 UTC (permalink / raw)
To: gcc-bugs
# 1 "strcmp.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "strcmp.c"
int strcmp (const char *, const char *);
int
strcmp (const char *s1, const char *s2)
{
if ((!s1 && s2) || (s1 && !s2))
return (int) (s1 - s2);
if (s1 == s2)
return 0;
while (*s1 == *s2++)
if (*s1++ == '\0')
return 0;
return (*(unsigned char *)s1 - *(unsigned char *)--s2);
}
The first conditional is eliminated causing a crash when a pointer is null.
Code is correct when -fno-tree-vrp is specified.
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu8'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-c' '-mtune=generic'
'-march=i486'
/usr/lib/gcc/i486-linux-gnu/4.4.1/cc1 -E -quiet -v strcmp.c
-D_FORTIFY_SOURCE=2 -mtune=generic -march=i486 -O3 -fpch-preprocess
-fstack-protector -o strcmp.i
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.1/include
/usr/lib/gcc/i486-linux-gnu/4.4.1/include-fixed
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-c' '-mtune=generic'
'-march=i486'
/usr/lib/gcc/i486-linux-gnu/4.4.1/cc1 -fpreprocessed strcmp.i -quiet -dumpbase
strcmp.c -mtune=generic -march=i486 -auxbase strcmp -O3 -version
-fstack-protector -o strcmp.s
GNU C (Ubuntu 4.4.1-4ubuntu8) version 4.4.1 (i486-linux-gnu)
compiled by GNU C version 4.4.1, GMP version 4.3.1, MPFR version
2.4.1-p2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 293503c4ddf766b61fc5ff6a5ff38cdc
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-c' '-mtune=generic'
'-march=i486'
as -V -Qy -o strcmp.o strcmp.s
GNU assembler version 2.20 (i486-linux-gnu) using BFD version (GNU Binutils for
Ubuntu) 2.20
COMPILER_PATH=/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/:/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../:/lib/:/usr/lib/:/usr/lib/i486-linux-gnu/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-c' '-mtune=generic'
'-march=i486'
--
Summary: tree-vrp eliminates needed conditioanl
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kevfox at cisco dot com
GCC host triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41946
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/41946] tree-vrp eliminates needed conditioanl
2009-11-05 2:41 [Bug c/41946] New: tree-vrp eliminates needed conditioanl kevfox at cisco dot com
@ 2009-11-05 10:07 ` rguenth at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-05 10:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2009-11-05 10:07 -------
Use -fno-builtin-strcmp or name your function differently. The standard
does not allow NULL arguments to strcmp.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41946
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-05 10:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-05 2:41 [Bug c/41946] New: tree-vrp eliminates needed conditioanl kevfox at cisco dot com
2009-11-05 10:07 ` [Bug c/41946] " rguenth at gcc dot gnu dot org
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).