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]

Re: Incompatibility between gcc and glibc: alphaev5-dec-linux-gnu



On Wed, 11 Mar 1998, M.Schimschak wrote:

> Here's the program which is compiled with errors by several gcc based
> compilers when used with optimization, basically when inlining is
> allowed (see below):
> 
> -------------------------------------------------------------------------------
> 
> #include <stdlib.h>
> #include <stdio.h>
> #include <math.h>
> 
> 
> int main(void)
> {
>   double     c=0;
>   double     d=0;
>   double     e[2];
> 
> 
>   e[0] = 1.0;
>   e[1] = 1.0;
> 
>   
>   printf("%5g %5g   %10g %10g\n",e[0], e[1], c, d);
> 
>   c = atan2(e[0], e[1]);
>   d = e[0] * e[0] + e[1] * e[1];
> 
>   printf("%5g %5g   %10g %10g\n",e[0], e[1], c, d);
> 
>   return 0;
> }
> 
> -------------------------------------------------------------------------------
> This program is supposed to produce the following output:
> 
> "    1     1                 0               0
>      1     1      0.7853981634               2"
> 
> Instead it produces the following output with several compilers and
> several optimization levels:
> 
> "    1     1                 0               0
>      1     1      0.7853981634     1.785398163"
>                                    ^^^^^^^^^^^

Results on a RH-5.0 system on alphaev5-dec-linux-gnu, glibc-2.0.6 from
RH-5.0 updates, compilers see below:

I need to link against libm all time, because there is no inline for atan2
in __math.h on my machine !

The foolowing results are achieved by standard gcc and by egcs:
gcc -v
Reading specs from
/usr/share/gcc2/lib/gcc-lib/alphaev5-dec-linux-gnu/2.8.1/specs
gcc version 2.8.1
egcc -v
Reading specs from
/usr/local/share/egcs/lib/gcc-lib/alphaev5-dec-linux-gnu/egcs-2.91.13/specs
gcc version egcs-2.91.13 980308 (gcc-2.8.0 release)
 
gcc inline01.cc -o bug -lm                      correct
gcc -O1 inline01.cc -o bug -lm                  correct
gcc -O2 inline01.cc -o bug -lm                  correct
gcc -O3 inline01.cc -o bug -lm                  correct
gcc -finline -O3 inline01.cc -o bug -lm         correct

Jochen

 


-----------------------------------------------------------------------
  Jochen K"upper

  Heinrich-Heine-Universit"at D"usseldorf   jochen@uni-duesseldorf.de
  Institut f"ur Physikalische Chemie I
  Universit"atsstr. 1, Geb 26.43 Raum 02.29    phone ++49-211-8113681
  40225 D"usseldorf                            fax   ++49-211-8115195
  Germany             http://www-public.rz.uni-duesseldorf.de/~jochen
-----------------------------------------------------------------------




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