incorrect output of mktime or sth else

Bug #900994 reported by Junjie Wu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-4.5 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I have some weird output for the attached simple code. I tested on different machines and the following line is what I used to compile/run the code.
for i in {1..10}; do rm -f date && g++ -o date -Wall -Wextra date2.cc && ./date; done

I am in EST timezone (GMT-5), and expected output is:
2011 1 1 0 0 5
18000

All gcc/g++ are installed using the package system without any customization.

==================
First set of machines, Ubuntu 11.04 64bit
Linux ******* 2.6.38-13-generic #52-Ubuntu SMP Tue Nov 8 16:53:51 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
Linux ******* 2.6.38-12-server #51-Ubuntu SMP Wed Sep 28 16:07:08 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
==================
Gcc works 100% fine, but g++-4.5.2 and 4.4.5 both gave wrong results SOMETIMES.
I reproduced this behavior on my own desktop, and two servers.

2011 1 1 0 0 5
14400
2011 1 1 0 0 5
18000
2011 1 1 0 0 5
18000
2011 1 1 0 0 5
14400
2011 1 1 0 0 5
14400
2011 1 1 0 0 5
18000
2011 1 1 0 0 5
18000
2011 1 1 0 0 5
14400
2011 1 1 0 0 5
18000
2011 1 1 0 0 5
18000

===================
Second set of machines, Ubuntu 11.10 64bit
Linux ubuntu-VB 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
Linux ******* 3.0.0-12-server #20-Ubuntu SMP Fri Oct 7 16:36:30 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
===================
gcc/g++4.6.1, 4.5.4, 4.4.6 all gave wrong results, consistently. I reproduced same behavior on my VIrtualbox machine and a real server.
2011 1 1 0 0 5
14400

===================
Third machine (no bug)
RedHat EL5 (in university)
Linux ******* 2.6.18-274.7.1.el5 #1 SMP Mon Oct 17 11:57:14 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
===================
*******% g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-51)

Btw, I am aware of the fact that the behavior seems to be independent of the version of gcc/g++, but Ubuntu version. I only tested all gcc/g++ versions available in the package system. On 11.04, gcc always output correctly and g++ produce inconsistent results. On 11.10, gcc/g++ all produce wrong results consistently (off by -3600). This could be some bug outside gcc/g++, but should at least be a problem of Ubuntu configuration. The machines used here are all independently installed/configured by different people.

Another side note:
If I remove line 8 and 9, the behavior will be different. On 11.04, it's the same. On 11.10, gcc will consistently output 14400, while g++ output inconsistently (18000 or 14400).

Revision history for this message
Junjie Wu (wujj) wrote :
Revision history for this message
Junjie Wu (wujj) wrote :

After more debugging, I can confirm it's a runtime problem. If I change the command to:

for i in {1..10}; do ./date; done

Same thing still happens.

Revision history for this message
Junjie Wu (wujj) wrote :

wrong code indeed. Sorry

Changed in gcc-4.5 (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.