This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] libstdc++/5045: wrong numeric_limits::digits10 forinteger types
Paolo Carlini <pcarlini@unitus.it> writes:
> Nathan Myers wrote:
>
> > On Sat, Dec 08, 2001 at 01:37:46AM +0100, Paolo Carlini wrote:
> > > Benjamin Kosnik wrote:
> > >
> > > > > May I apply the following patch?
> > > > Please wait for Gaby to ok and make a test case please.
> > > In case Gaby ok the patch this is what I propose for the testsuite.
> > > + VERIFY( __glibcpp_s8_digits10 == 2 );
> > > + VERIFY( __glibcpp_u8_digits10 == 2 );
> > > + VERIFY( __glibcpp_s16_digits10 == 4 );
> > > + VERIFY( __glibcpp_u16_digits10 == 4 );
> > > + VERIFY( __glibcpp_s32_digits10 == 9 );
> > > + VERIFY( __glibcpp_u32_digits10 == 9 );
> > > + VERIFY( __glibcpp_s64_digits10 == 18 );
> >
> > I agree that Paolo's changes are correct, according to the
> > spirit of LAI-1 that numeric_traits is based on. I recommend
> > we go ahead and commit.
>
> Thanks Nathan. I will wait just a little bit more for Gaby, then will commit.
While I believe the above is correct (I reported the problem after
all), applying it will affect the new number input code in the file
libstdc++-v3/include/bits/locale_facet.tcc.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=3720&database=gcc
In locale_facets.tcc digits10 is used to determine the maximum number
of digits to read, with the above patch it will read one fewer. I
think one has to read digits10+1 digits to allow the full range of
input values.
Philip