This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/34423] Reading doubles smaller than 1e-308 in gcc 4.2.2 on os x
- From: "conley at astro dot utoronto dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Dec 2007 20:08:05 -0000
- Subject: [Bug libstdc++/34423] Reading doubles smaller than 1e-308 in gcc 4.2.2 on os x
- References: <bug-34423-15496@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from conley at astro dot utoronto dot ca 2007-12-10 20:08 -------
Subject: Re: Reading doubles smaller than 1e-308 in gcc 4.2.2 on os x corrupts
future reads
Ok, thanks for the information. So the mystery
is then: why is failbit set on that read in 4.2.2
and not 4.0.1 (and whatever version of libstdc++
each is linking against). Inserting a little check and error message
code does confirm that
1) On 4.2.2, failbit is set after the read, and clearing it
does make the next read work correctly. But the
first read does fail, and results in the wrong value.
2) On 4.0.1, failbit is _not_ set after the read, and the
whole thing works the way it should.
After all, 1e-321 is not too small for a 64 bit double,
so the read should work and there should be no underflow.
Of course, this may well be related
to some change in the stdc++ libraries or a mistake on
the part of whomever packaged this for fink/OS X.
On my machine, gcc 4.0.1 links against libstdc++-6.0.4
and gcc 4.2.2 against libstdc++-6.0.9
Alex
On 10 Dec 2007 19:26:56 -0000, pcarlini at suse dot de
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #2 from pcarlini at suse dot de 2007-12-10 19:26 -------
> What you call "corruption of future reads" is just failbit set, due to
> underflow, evidently. You can simply reset it to goodbit and proceed. That
> said, I have no idea why the behavior is different in 4.2.2 vs 4.0.1, since
> nothing changed in the relevant part of the C++ library (of our competence),
> which simply does in both releases:
>
> double __d = strtod(__s, &__sanity);
> if (__sanity != __s && errno != ERANGE)
> __v = __d;
> else
> __err |= ios_base::failbit;
>
> Note, however, that it is implementation defined in the underlying C library
> whether errno is set to ERANGE by strtod on underflow. Maybe you also updated
> the C library, which changed behavior lately on darwin? Anyway, it is very
> unlikely that at this point in the release story of 4.2.x the C++ library side
> will change. On the other hand, it will change for 4.3.0: there we avoid using
> ERANGE completely and underflow never sets failbit, the behavior that you want.
>
>
> --
>
> pcarlini at suse dot de changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Component|c++ |libstdc++
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34423
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34423