public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61166] New: overflow when parse number in std::duration operator""
@ 2014-05-13  7:42 kan.liu.229 at gmail dot com
  2014-05-13 10:55 ` [Bug libstdc++/61166] " paolo.carlini at oracle dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: kan.liu.229 at gmail dot com @ 2014-05-13  7:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61166

            Bug ID: 61166
           Summary: overflow when parse number in std::duration operator""
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kan.liu.229 at gmail dot com

overflow may occur when using a number whose size exceeds sizeof(unsigned) in
chrono_literals. Because the parse classes in include/bits/parse_number.h just
use *unsigned* for member type. However, it should accept *unsigned long long*
I think. This issue also exists in trunk I think.

#include <chrono>

using namespace std;
using namespace std::chrono;

int main() {
    // std::numeric_limits<unsigned>::max() == 4294967295
    cout << 429496729510 << endl;
    cout << (429496729510h).count() << endl;
    return 0;
}

And the result is

429496729510 
926648584


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

end of thread, other threads:[~2014-06-23 15:39 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-13  7:42 [Bug libstdc++/61166] New: overflow when parse number in std::duration operator"" kan.liu.229 at gmail dot com
2014-05-13 10:55 ` [Bug libstdc++/61166] " paolo.carlini at oracle dot com
2014-05-13 13:34 ` emsr at gcc dot gnu.org
2014-05-13 13:41 ` kan.liu.229 at gmail dot com
2014-05-13 13:46 ` kan.liu.229 at gmail dot com
2014-05-13 18:06 ` 3dw4rd at verizon dot net
2014-05-14 14:12 ` kan.liu.229 at gmail dot com
2014-05-14 18:15 ` redi at gcc dot gnu.org
2014-05-14 18:15 ` redi at gcc dot gnu.org
2014-05-15 19:09 ` redi at gcc dot gnu.org
2014-05-16  5:55 ` kan.liu.229 at gmail dot com
2014-05-16  7:17 ` redi at gcc dot gnu.org
2014-05-16  7:32 ` kan.liu.229 at gmail dot com
2014-05-16  9:31 ` redi at gcc dot gnu.org
2014-06-23 15:39 ` redi at gcc dot gnu.org

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