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]

A bug in egcs-c++-1.1.2



Hello,

I am running the egcs c++ compiler on an intell machine
with redhat 6.1. The rpm package that I have is:

egcs-c++-1.1.2-24.rpm
egcs-1.1.2-24.rpm
egcs-g77-1.1.2-24.rpm

The VERY simple program produces two different results
depending on the level of optimization.

the program listing is:

-------------------------
#include <iostream.h>

main() {

 double min = 0.0;
 double max = 0.5;
 double width = 0.01;
 cout << (int) (((max - min) / width) + 1) << endl;

}

---------------------------

when I compile it with the command:

g++ test.c -o x

the number that is printed is 50 (which is wrong).

when I compile it with the command:

g++ -O2 test.c -o x

The number that gets printed is 51 (which is correct).

Please let me know if I am overlooking anyuthing.
Note I tried using the static_cast<int> instead
of (int) and the same thing happend.


Also, I tried running the same program on a linux
box running redhat 6.0 with egcs-c++-1.1.2-12.rpm
and I had the same problems.

Please send me some feedback soon if you can as
I am porting a large project for my company
and this bug was very hard to track.

Thanks,
Abed 

-- 
Abed M. Hammoud, D.Sc.                          abed@anatomic.com
Medtronic                                       Office: (303) 439-9709
x210
Colorado, USA		                        http://www.anatomic.com/abed


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