Hello, This was posted to linux.redhat.devel newsgroup. Looks like a bug, but then my status as a programmer is beginner. :-) Regards, Jim H ,--------------- Forwarded message (begin) Subject: const array bug in g++? From: [EMAIL PROTECTED] Date: Wed, 18 Apr 2001 10:47:52 -0700 Hi, An early version was posted a couple of days ago to comp.lang.c++.moderated. I think I need to enlarge the audience with a little bit new testing results. The following simple program #include <iostream> using namespace std; const float C = 0.5F; const float C1[2] = {0.5F, 0.5F}; const float C2[2][2] = {{C1[0], C1[0]}, {C1[1], C1[1]}}; //const float C2[2][2] = {{C, C}, {C, C}}; int main() { cout<<"C1[0] = "<<C1[0]<<endl; cout<<"C2[0][0] = "<<C2[0][0]<<endl; return 0; } outputs the wrong result when it is compiled with gcc v2.96. I tried with g++ (gcc version 2.96 20000731 from update file gcc-2.96-69.i386.rpm) under Red Hat Linux 7.0, as well as the g++ (gcc version 2.96 20000731 from gcc-2.96-81.i386.rpm) under the just released RedHat 7.1 (2.96-81), both gave me the wrong result for C2[0][0] (which should be 0.5): C1[0] = 0.5 C2[0][0] = 0 If I use the the statement that is commented out above, the output is right.The program works fine with Microsoft VC++ 6.0, and also works with old gcc (the autual program was last tested about 1.5 years ago. I think it was compiled with gcc v2.73). The compiled program links to the following libraries: libstdc++-libc6.2-2.so.3 => /usr/lib/libstdc++-libc6.2-2.so.3 (0x40027000) libm.so.6 => /lib/i686/libm.so.6 (0x4006a000) libc.so.6 => /lib/i686/libc.so.6 (0x4008e000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) under RedHat 7.1, and to libstdc++-libc6.2-2.so.3 => /usr/lib/libstdc++-libc6.2-2.so.3 (0x40021000) libm.so.6 => /lib/libm.so.6 (0x40064000) libc.so.6 => /lib/libc.so.6 (0x40083000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) under RedHat 7.0, if the info helps. Does anyone can explain why the gcc 2.96 does not output the correct answer, or it is simply a bug in this version of gcc (or the libraries)? Thanks in advance. Regards, Bin ----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web ----- http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups NewsOne.Net prohibits users from posting spam. If this or other posts made through NewsOne.Net violate posting guidelines, email [EMAIL PROTECTED] `--------------- Forwarded message (end) _______________________________________________ Redhat-devel-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-devel-list