This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: std::isfinite broken?
- From: Eus <eus at member dot fsf dot org>
- To: Neal Becker <ndbecker2 at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 30 Jul 2008 08:15:54 -0700 (PDT)
- Subject: Re: std::isfinite broken?
- Reply-to: eus at member dot fsf dot org
Hi Ho!
--- On Tue, 7/29/08, "Neal Becker" <ndbecker2@gmail.com> wrote:
> Paolo Carlini wrote:
>
> > ... ah, ok, now I see what you meant, you meant that x is *not* finite,
> > still, std::isfinite(x) != 0. Still, testcase badly needed...
> >
> > Paolo.
> #include <cmath>
> #include <stdexcept>
>
> int main () {
> double x = log (0);
> if (not std::isfinite (x)) {
> throw std::runtime_error ("not finite");
> }
> }
>
> Compiled with -O3 -ffast-math will not throw.
It worked with me.
Here is the record:
eus@experimental:~/shared/del/PHP$ cat x.c
#include <iostream>
#include <cmath>
#include <stdexcept>
int main () {
double x = log (0);
if (not std::isfinite (x)) {
std::cout << "Inside if" << std::endl;
}
std::cout << "Outside if" << std::endl;
return 0;
}
eus@experimental:~/shared/del/PHP$ g++ -o a -O3 -ffast-math x.c
eus@experimental:~/shared/del/PHP$ ./a
Inside if
Outside if
eus@experimental:~/shared/del/PHP$ g++ -v
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.3.6/specs
Configured with: ../gcc-3.3.6/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.3.6
Best regards,
Eus