From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: X-Archive-Original-Message-ID: <199603152047.PAA02208@Adeno.wistar.upenn.edu> Date: Fri, 15 Mar 1996 15:47:42 -0500 (EST) From: Jeff Taylor Subject: GCC bug??? Hello Alpha users - I'm not sure if this qualifies as a bug in the technical sense, but it seems at least to be an inconsistany between Alpha Linux/GCC and x86 Linux/GCC. I ran into this problem with the math lib function pow(), but it may occur elsewhere. It occurs when incorrectly typed variables (ints, or longs) are passed to the pow() function, which as I understand, expects doubles. I compiled the following code with GCC on a Linux/Pentium system and it works fine: #include #include main() { int i; int x; for (i=0;i<6;i++) { x=pow(2,i); printf("%d %ld\n",i,x); } } Output is: 0 1 1 2 2 4 3 8 4 16 5 32 The same code compiled on Linux/Alpha gives : #include #include main() { int i; int x; for (i=0;i<6;i++) { x=pow(2,i); printf("%d %ld\n",i,x); } } Output : 0 1 1 2 2 4 3 7 4 15 5 32 It seems to be something strange in the conversion from one type to another. For example : main() { int i; double x,y; for (i=0;i<21;i++) { x= pow(2.0,i); y = (int)x; printf("%d %g %g\n",i,x,y); } } Gives Output: 0 1 1 1 2 2 2 4 4 3 8 7 4 16 15 5 32 32 There are no warnings of potential problems at compile time and because this problem does not occur with the x86 GCC (I haven't tried any other platforms). Being a C beginner, I'm not sure what should happen, but I think at least a warning is warrented. Jeff Taylor