Bug 16920 - possible generation of broken asm code? (C, C++, gcc 3.4.1)
Summary: possible generation of broken asm code? (C, C++, gcc 3.4.1)
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ABI, wrong-code
Depends on:
Blocks:
 
Reported: 2004-08-08 16:20 UTC by Wojtek Rolecki
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
wrong timestamps test case (8.08 KB, application/octet-stream)
2004-08-08 16:22 UTC, Wojtek Rolecki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wojtek Rolecki 2004-08-08 16:20:38 UTC
attached example program produces wrong results when compiled as 64 bit binary.
it works ok when compiled with -Os optimization OR into 32 bit binary (forced
with -m32 switch). 

it grabs two timestamps (format: YYYYMMDDHH:MM:SS), converts them with strptime
into tm struct and displays unix epoch time generated with mktime() - when
compiled as 64 bit binary, one timestamp has wrong value (the difference between
original timestamps is 180s, whereas it shows it's 3420 seconds after using
mktime()). it shows proper 180 seconds difference when compiled with -m32 or -Os.

my gcc -v:
Reading specs from /usr/lib/gcc/x86_64-pc-linux-gnu/3.4.1/specs
Configured with: /usr/local/portage/portage/gcc-3.4.1/work/gcc-3.4.1/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/3.4
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.1/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/3.4/info --enable-shared
--host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++,objc --enable-threads=posix --enable-long-long
--disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio
--enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.1/include/g++-v3
--with-local-prefix=/usr/local --disable-werror --enable-shared --enable-nls
--without-included-gettext --enable-multilib --enable-__cxa_atexit
--enable-clocale=gnu
Thread model: posix
gcc version 3.4.1  (Gentoo Linux 3.4.1, ssp-3.4-2, pie-8.7.6.3)
Comment 1 Wojtek Rolecki 2004-08-08 16:22:25 UTC
Created attachment 6906 [details]
wrong timestamps test case
Comment 2 Andrew Pinski 2004-08-08 18:16:54 UTC
So this fails at -O0 right?
Also does this fail with an unmodified compiler as the compiler you are using has been modified by 
Gentoo.
Comment 3 Wojtek Rolecki 2004-08-08 18:18:58 UTC
yes, it behaves ugly with -O0 (only with -Wall in fact). I'll try to test how
does it work with vanilla gcc 3.4.1 soon.
Comment 4 Wojtek Rolecki 2004-08-08 19:42:09 UTC
the bug is absent with plain gcc from gnu.org. moreover, the original bug seems
to be gone after glibc upgrade, so I guess this successfully classifies this bug
as missed...
Comment 5 Andrew Pinski 2004-08-08 19:43:22 UTC
So closing as worksforme.
Comment 6 Wojtek Rolecki 2004-08-08 20:47:18 UTC
unfortunately - the "bug" is still there until I have setlocale(LC_TIME, "C")
before calling sesstime(). in fact it generates wrong results whatever LC_TIME
value I use (and 64 bit code is generated). setlocale() has no effect when
compiled with -m32 (it works ok then). this makes me wonder if it may be rather
some glibc issue rather than gcc problem. I'd appreciate any hints on that.