Unexpected behaviour printing twice the same variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

This program has a strange behaviour, probably due to FP optimizations using
the -O1 or -O2 or -O3 (I can resolve it with the GCC compilation flag
-ffloat-store).
It should produce the same output twice (because it prints the same variable
in 2 consecutive lines), but it does not; there are some errors on the last
digits. Someone can explain me what happen?

Source:

http://old.nabble.com/file/p33858981/bug.c bug.c 


Compile:

	gcc -O3 -o bug bug.c  

Output:

	132.316432 132.316437
	108.085940 108.085938
	134.695360 134.695358
	123.992232 123.992233


I tested it with the following systems:

Intel i5, Ubuntu Linaro, kernel 3.0.0-19-generic, GCC 4.6.1-9ubuntu3 
Intel i7, Ubuntu Linaro, kernel 2.6.38-15-generic, GCC 4.5.2-8ubuntu4

-- 
View this message in context: http://old.nabble.com/Unexpected-behaviour-printing-twice-the-same-variable-tp33858981p33858981.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux