public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Re: check if is NaN
[not found] <8mr7bo$bf1$1@nnrp1.deja.com>
@ 2000-08-09 7:49 ` Thomas.Koenig
2000-08-09 13:06 ` Toon Moene
0 siblings, 1 reply; 2+ messages in thread
From: Thomas.Koenig @ 2000-08-09 7:49 UTC (permalink / raw)
To: gcc-bugs
(Cc: to gcc-bugs@gcc.gnu.org)
In article <8mr7bo$bf1$1@nnrp1.deja.com>, <ezio_riva@my-deja.com> wrote:
>a) I 'm using g77 but I need to use the option -ffast-math.
I was quite surprised that
external isnand
logical isnand
double precision a
a = acos(1.2)
print *,a,isnand(a)
end
logical function isnand(a)
double precision a
isnand = a .ne. a
end
produced
NAN F
with GNU Fortran 0.5.25 19991030 (prerelease) on Linux i386 and
compilation with -O4 -ffast-math. Inspection of the generated assembly
code showed
.globl isnand_
.type isnand_,@function
isnand_:
pushl %ebp
movl %esp,%ebp
xorl %eax,%eax
leave
ret
which shows that the test was optimized away.
I'm not sure wether to classify this as a bug or not. The documentation
warns that -ffast-math makes programs non IEEE-conforming, but still...
What I would really like, I suppose, would be an ISNAN intrinsic
function.
BTW,
isnand = a.ge. 0. .or. a .ne. 0.
works, but a very clever optimizer could also optimize this away...
>From aoliva@redhat.com Wed Aug 09 09:01:00 2000
From: Alexandre Oliva <aoliva@redhat.com>
To: "Tim Prince" <tprince@computer.org>
Cc: "Markus Werle" <markus@lufmech.rwth-aachen.de>, <gcc-bugs@gcc.gnu.org>
Subject: Re: Funny warning message: greater than minimum
Date: Wed, 09 Aug 2000 09:01:00 -0000
Message-id: <orpunil96f.fsf@guarana.lsd.ic.unicamp.br>
References: <399160F4.86730B9B@lufmech.rwth-aachen.de> <000901c0020d$d18c7f10$0100000a@TIMYX18EWDT6RQ>
X-SW-Source: 2000-08/msg00186.html
Content-length: 431
On Aug 9, 2000, "Tim Prince" <tprince@computer.org> wrote:
> Perhaps this warning belongs under -pedwarn or whatever.
Indeed, it does :-)
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: check if is NaN
2000-08-09 7:49 ` check if is NaN Thomas.Koenig
@ 2000-08-09 13:06 ` Toon Moene
0 siblings, 0 replies; 2+ messages in thread
From: Toon Moene @ 2000-08-09 13:06 UTC (permalink / raw)
To: Thomas.Koenig; +Cc: gcc-bugs
Thomas.Koenig@cologne.de wrote:
> >a) I 'm using g77 but I need to use the option -ffast-math.
>
> I was quite surprised that
>
> external isnand
> logical isnand
> double precision a
> a = acos(1.2)
> print *,a,isnand(a)
> end
> logical function isnand(a)
> double precision a
> isnand = a .ne. a
> end
>
> produced
>
> NAN F
>
> with GNU Fortran 0.5.25 19991030 (prerelease) on Linux i386 and
> compilation with -O4 -ffast-math. Inspection of the generated assembly
> code showed
>
> .globl isnand_
> .type isnand_,@function
> isnand_:
> pushl %ebp
> movl %esp,%ebp
> xorl %eax,%eax
> leave
> ret
>
> which shows that the test was optimized away.
>
> I'm not sure wether to classify this as a bug or not. The documentation
> warns that -ffast-math makes programs non IEEE-conforming, but still...
Exactly - moreover, I have warned about this behaviour in the past on
comp.lang.fortran.
I'm sorry - the whole purpose of -ffast-math is to cut corners,
especially where following the IEEE standard zealously would incur
significant overhead.
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://g95.sourceforge.net/ (under construction)
>From mschwendt@web.de Wed Aug 09 14:57:00 2000
From: Michael Schwendt <mschwendt@web.de>
To: gcc-bugs@gcc.gnu.org
Subject: Re: Member initialization of arrays of constants
Date: Wed, 09 Aug 2000 14:57:00 -0000
Message-id: <Pine.LNX.4.21.0008092343210.1338-100000@faldor.intranet>
References: <Pine.LNX.4.21.0007240337290.955-100000@faldor.intranet>
X-SW-Source: 2000-08/msg00195.html
Content-length: 825
Hi!
After a discussion on comp.std.c++ and quite some time spent on
reading the Standard and Bjarne Stroustrup's book, I feel sort of
brain-washed and tend to believe that this code must not compile
without errors because struct A contains uninitialized const members
that either require a constructor or cannot be initialized
explicitly:
struct A
{
const char c[4]; // ill-formed
const int i; // requires constructor
};
class C
{
static const A a;
};
const A C::a = { 'T','E','S','T', 2 }; // error! struct A is bad
In Stroustrup's "C++ Programming Language" 3rd Edition, see:
10.4.2
10.4.6.1
10.4.6.2
In the C++ Standard see:
8.5/9
9/4
9.2/4
9.2/5
Conclusively,
Regards,
Mike
--
"I don't need luck. I got a system. I play all the odd red numbers."
- Danny Wilde (The Persuaders!)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-08-09 13:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <8mr7bo$bf1$1@nnrp1.deja.com>
2000-08-09 7:49 ` check if is NaN Thomas.Koenig
2000-08-09 13:06 ` Toon Moene
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).