This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

g++ 2.95 produces wrong code


I sent this some weeks ago but got no reply.

The following code gives me NaN instead of the expected 2.
This error occurs with gcc-2.95, 2.95.1, 2.95.2 (cvs).
Regards,
Thomas


[tom@eeipmf tom]$ cat driver.cc
#include <iostream>
 
struct A
{
    A() : d_(0.0){}
    double d_;
};
 
A g() { return A(); }
 
A f() {  g();  return A(); }
 
int main( int ac, char* av[] )
{
    for( int i=0; i<7; ++i )f(); 
    double d3 = 1.0;
    double d4 = d3+1.0;
    cout << d3 << " " << d4 << endl;
}
 
[tom@eeipmf tom]$ g++ driver.cc
[tom@eeipmf tom]$ ./a.out
1    NaN
[tom@eeipmf tom]$ g++ -v
Reading specs from /opt/gcc295/lib/gcc-lib/i686-pc-linux-gnu/2.95/specs
gcc version 2.95 19990728 (release)
[tom@eeipmf tom]$


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]