This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21464] New: assembler code is not generated for uint64_t comparison with -O
- From: "moonz at kaist dot ac dot kr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 May 2005 09:31:23 -0000
- Subject: [Bug c/21464] New: assembler code is not generated for uint64_t comparison with -O
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
input:
====== a.c =====
#include <stdio.h>
#include <inttypes.h>
int main() {
uint64_t pos = 1;
pos = 1;
if (pos < 1 || pos > 0xffffffffffffffffULL) {
printf("fail\n");
return 1;
}
printf("ok\n");
return 0;
}
===== end of a.c =====
command lines:
$ gcc a.c
$ ./a.out
ok
$ gcc -O a.c
$ ./a.out
fail
assembler code for comparison of pos is not generated correctly.
it should test, at least, pos < 1,
but generated code act like if the condition was true.
if "pos > 0xffffffffffffffffUL" is not present, it runs successfully.
definitely, optimization bug while preevaluating the condition at compile time.
my gcc version information is:
$ gcc -v
Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.3-20050110/specs
Configured with: /var/tmp/portage/gcc-3.4.3.20050110-r2/work/gcc-3.4.3/configure
--enable-version-specific-runtime-libs --prefix=/usr
--bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.4.3-20050110
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.3-20050110/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3-20050110
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3-20050110/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3-20050110/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.3-20050110/include/g++-v3
--host=i686-pc-linux-gnu --disable-altivec --enable-nls
--without-included-gettext --with-system-zlib --disable-checking
--disable-werror --disable-libunwind-exceptions --disable-multilib
--disable-libgcj --enable-languages=c,c++,f77 --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 3.4.3-20050110 (Gentoo Linux 3.4.3.20050110-r2,
ssp-3.4.3.20050110-0, pie-8.7.7)
--
Summary: assembler code is not generated for uint64_t comparison
with -O
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: moonz at kaist dot ac dot kr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21464