public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44198] New: Constant floating point values are mutable (with '-O1')
@ 2010-05-19 18:00 AlekM at hotmail dot com
2010-05-19 18:02 ` [Bug c/44198] " pinskia at gcc dot gnu dot org
2010-05-19 18:05 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: AlekM at hotmail dot com @ 2010-05-19 18:00 UTC (permalink / raw)
To: gcc-bugs
The example code below, compiled on x86 with gcc versions 4.1.2 through 4.4.0,
aborts when executed.
#include <stdlib.h>
#include <assert.h>
int main(void)__attribute__ ((optimize("O1"))); // Also with '-O2'
int main(void)
{
const float a = rand(); // Any function call that returns 1804289383 will do
volatile float tmp=a;
assert(tmp==a); // This one aborts
assert(tmp==a); // This one passes (if line above is replaced with printf)
}
If you replace assert() with two consecutive printf("%f ", a), two different
values are displayed for the constant variable a.
--
Summary: Constant floating point values are mutable (with '-O1')
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: AlekM at hotmail dot com
GCC build triplet: gcc version 4.4.0 20090514 (Red Hat 4.4.0-6) (GCC)
GCC host triplet: Linux hld-lx 2.6.18-128.7.1.el5 #1 SMP Mon Aug 24
08:20:55 EDT 2
GCC target triplet: same as above
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44198
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-19 18:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-19 18:00 [Bug c/44198] New: Constant floating point values are mutable (with '-O1') AlekM at hotmail dot com
2010-05-19 18:02 ` [Bug c/44198] " pinskia at gcc dot gnu dot org
2010-05-19 18:05 ` pinskia 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).