https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61626
Bug ID: 61626
Summary: Cast temporary produces wrong result
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: meidingerc1 at gmail dot com
Created attachment 33015
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33015&action=edit
The source and .i and others required by the instructions.
This code:
#include
int main() {
long long sm = 0x7FFF;
double dm = (double)sm;
double value = 9223372036854775800.0;
printf("%s\n", (((double)sm) == value ? "true" : "false"));
printf("%s\n", (dm == value ? "true" : "false"));
}
causes the problem.
One would expect that both lines of output would be the same, but the bug
causes
the output to be
false
true
The bug occurs in gcc version 4.8.2 on the 32-bit Intel version of Kubuntu
14.04.
It also occurs in g++ version 4.8.2 on the same system, and on other current
and recent 32-bit Intel releases of Kubuntu and Fedora with various versions of
g++ 4.7 and 4.8.
The bug does not occur in g++ on any 64-bit Intel system I tried, with versions
4.7.* and 4.8.*.
The bug does not occur in g++ on a 32-bit ARM system (Chromebook) running
Gentoo and g++ version 4.8.2.
Furthermore, the bug does not occur in gcc or g++ version 4.9.0 on the 32-bit
version of Kubuntu 14.04.
Was the bug fixed by accident or purposefully? I couldn't find any mention of
the bug in the database.
Perhaps the only actions needed are to figure out why the bug occurs in earlier
versions, and add a regression test to make sure it doesn't recur.
A .tar.bz2 file containg the relevant files is attached.