public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/39168]  New: Incorrect interpritation of CHAR_MAX inside grouping string in monetary and numeric facets.
@ 2009-02-12 15:27 tsyvarev at ispras dot ru
  2009-02-12 15:30 ` [Bug libstdc++/39168] " tsyvarev at ispras dot ru
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: tsyvarev at ispras dot ru @ 2009-02-12 15:27 UTC (permalink / raw)
  To: gcc-bugs

Description of numpunct<>::do_grouping() (22.2.3.1.2, p3): 

Returns: A basic_string<char> vec used as a vector of integer values, in which
each element vec[i] represents the number of digits in the group at position i,
starting with position 0 as the rightmost group. If vec.size() <= i, the number
is the same as group (i-1); if (i<0 || vec[i]<=0 || vec[i]==CHAR_MAX), the size
of the digit group is unlimited. 

But num_put and num_get implementations don't interpret condition
(vec[i]==CHAR_MAX) as condition of group with unlimited size, but interpret
value CHAR_MAX as regular size of digits group.

According to the code, condition (static_cast<signed char>(vec[i]) > 0) is used
as an indicator of regular group size. This means range 1..127 for vec[i]
values.

But on architectures with char ~ signed char(e.g. x86), CHAR_MAX is 127, so the
range shouldn't include value 127.

In tests, string(1, CHAR_MAX) is used as grouping string. Like string() and
string(1, -1), this should disable grouping at all.
But on architectures with char ~ signed char tests failed. On architectures
with char ~ unsigned char or when CHAR_MAX replaced with -1, all became ok.


-- 
           Summary: Incorrect interpritation of CHAR_MAX inside grouping
                    string in monetary and numeric facets.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tsyvarev at ispras dot ru


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39168


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2009-02-15 16:50 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-12 15:27 [Bug libstdc++/39168] New: Incorrect interpritation of CHAR_MAX inside grouping string in monetary and numeric facets tsyvarev at ispras dot ru
2009-02-12 15:30 ` [Bug libstdc++/39168] " tsyvarev at ispras dot ru
2009-02-12 15:33 ` tsyvarev at ispras dot ru
2009-02-12 15:58 ` [Bug libstdc++/39168] Incorrect interpretation " paolo dot carlini at oracle dot com
2009-02-12 16:49 ` sebor at roguewave dot com
2009-02-12 17:06 ` paolo dot carlini at oracle dot com
2009-02-12 17:53 ` paolo dot carlini at oracle dot com
2009-02-13 11:21 ` tsyvarev at ispras dot ru
2009-02-13 11:31 ` paolo dot carlini at oracle dot com
2009-02-13 11:39 ` paolo dot carlini at oracle dot com
2009-02-13 13:41 ` tsyvarev at ispras dot ru
2009-02-13 13:43 ` paolo dot carlini at oracle dot com
2009-02-13 15:05 ` tsyvarev at ispras dot ru
2009-02-13 15:11 ` paolo dot carlini at oracle dot com
2009-02-13 15:21 ` paolo dot carlini at oracle dot com
2009-02-13 15:39 ` tsyvarev at ispras dot ru
2009-02-13 15:49 ` paolo dot carlini at oracle dot com
2009-02-14 21:21 ` sebor at roguewave dot com
2009-02-14 21:42 ` sebor at roguewave dot com
2009-02-14 21:55 ` paolo dot carlini at oracle dot com
2009-02-14 21:59 ` sebor at roguewave dot com
2009-02-15 16:48 ` paolo at gcc dot gnu dot org
2009-02-15 16:50 ` paolo dot carlini at oracle dot com

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).