* GCC bug???
@ 1996-03-15 20:47 Jeff Taylor
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Taylor @ 1996-03-15 20:47 UTC (permalink / raw)
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 <stdlib.h>
#include <math.h>
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 <stdlib.h>
#include <math.h>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: GCC bug???
[not found] <199603152047.PAA02208@Adeno.wistar.upenn.edu>
@ 1996-03-15 22:54 ` yxc02740
0 siblings, 0 replies; 4+ messages in thread
From: yxc02740 @ 1996-03-15 22:54 UTC (permalink / raw)
>
>
> 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:
It is not a GCC bug, but it is a library bug. It turns out that the
linux/alpha's libm.a is not only slow, but also buggy. You problem is caused
by a last digit rounding error for pow() function. I don't know if a standard
IEEE floating point library allows such error, but at least, a 487 chip
returns correct value.
The Alpha/Linux's math library has not been implemented, it is just copied
from generic RICS codes. I would like to know if sb. is working on this
problem, we difinetely need a better math library.
>
> #include <stdlib.h>
> #include <math.h>
>
> 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 <stdlib.h>
> #include <math.h>
>
> 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
>
yansong chen
yxc02740@bayou.uh.edu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: GCC bug???
@ 1996-03-15 23:52 David Mosberger-Tang
0 siblings, 0 replies; 4+ messages in thread
From: David Mosberger-Tang @ 1996-03-15 23:52 UTC (permalink / raw)
>>>>> On Fri, 15 Mar 1996 16:54:16 -0600 (CST), (cosc1) 95h02740 <yxc02740@Bayou.UH.EDU> said:
>> 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:
Yansong> It is not a GCC bug, but it is a library bug. It turns out
Yansong> that the linux/alpha's libm.a is not only slow, but also
Yansong> buggy.
Not just buggy and slow, but incomplete, too! E.g., the Bessel
functions are missing. Moreover, it doesn't support float operations
either (as opposed to double... :-)
Why am I so happy about it? Well, here is where GNU libc comes in: it
just switched to a new math library that looks fairly complete and is
specifically for IEEE-754. With it, I get:
<--begin script-->
$ uname -a
Linux koala.azstarnet.com 1.3.74 #60 Fri Mar 15 07:47:00 MST 1996alpha alpha
$ cat foo.c
#include <math.h>
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);
}
}
$ gcc foo.c -lm
$ ./a.out
0 1 1
1 2 2
2 4 4
3 8 8
4 16 16
5 32 32
<--end script-->
So it does seem to work fine. What's the catch? Well, I won't have
time to do any serious testing of libm any time soon (the GNU libc
folks are looking for a test suite, however, and I hear there may be
something that is freely available, so this may not be as bad as it
sounds). Since there do seem to be people out there that (a) have
more use for libm than I do (povray is about as tough as it gets with
me) and (b) are more knowledgable with math, I propose that interested
parties take a look at the libm as it comes with GNU libc. I'd be
happy to make a precompiled libm and the sources available so that
anybody interested could hack away. I see the following areas could
use improvements:
(1) The current Alpha hardware does not support exceptional
numbers (non-finite) such as denormals or infinities or NaNs.
This has two effects: First, it *may* affect the correctness of some
algorithms (e.g., the library may assume that the smallest finite
positive number divided by two gives a denormalized result,
not 0 as the Alpha hw provides by default). While this is
possible source of concern, I don't think it will be a major
headache (doesn't the x87 FPU do something similar? But maybe
I'm confusing it with the i960). More importantly: since the Alpha
hardware will trap on input of any non-finite number, there is no
*need* to check for such values. This often allows to speed up the
implementation significantly. The C compiler will tell you what
degree of IEEE compliance is in effect by the presence/absence of
two CPP macros:
_IEEE_FP => non-finite numbers are supported
(with current chips, via compiler/OS
support)
_IEEE_FP_INEXACT
=> non-finite numbers as well as the
IEEE INEXACT flag are supported
That is, if neither macro is defined, there is no point in
checking for (or generating) non-finite numbers.
(2) A lot of the float/double constants in the sources
reappear over and over again. It would be quite a bit
more efficient to gather those constants into a single
array. With current Linux/Alpha compiler technology,
this would typically save one memory access per constant.
Oh, I did tune Linus's sqrt() a little bit more and we're now pretty
competitive with the OSF/1 version (basically, we beat them whenever
you don't do sqrt() for a living---i.e., whenever not all of the sqrt
code/data is in the cache, which is not uncommon). It also seems to
be accurate: after testing it on 437,689,015,671 random numbers, I
haven't found a single case where the result would have deviated from
the result of the OSF/1 libm by a single bit.
But other than this, not much has happened libm wise, AFAIK.
--david
^ permalink raw reply [flat|nested] 4+ messages in thread
* gcc bug?
@ 1997-04-05 16:22 Michael Alan Dorman
0 siblings, 0 replies; 4+ messages in thread
From: Michael Alan Dorman @ 1997-04-05 16:22 UTC (permalink / raw)
I am using gcc-2.7.2.1 with the two patches from rth, compiled with
glibc2.1.
In compiling qmail, if I try to compile cdbmake_add.c with -O2, gcc
gets a signal 6 _every time_. If I change the optimization to -O, it
makes it through.
Is this a concise enough test case? Is there any more information I
can provide?
Mike.
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1997-04-05 16:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-03-15 20:47 GCC bug??? Jeff Taylor
[not found] <199603152047.PAA02208@Adeno.wistar.upenn.edu>
1996-03-15 22:54 ` yxc02740
-- strict thread matches above, loose matches on Subject: below --
1996-03-15 23:52 David Mosberger-Tang
1997-04-05 16:22 gcc bug? Michael Alan Dorman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox