From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14258 invoked by alias); 13 May 2014 07:42:33 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 14230 invoked by uid 48); 13 May 2014 07:42:30 -0000 From: "kan.liu.229 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/61166] New: overflow when parse number in std::duration operator"" Date: Tue, 13 May 2014 07:42:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kan.liu.229 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg01097.txt.bz2 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 using namespace std; using namespace std::chrono; int main() { // std::numeric_limits::max() == 4294967295 cout << 429496729510 << endl; cout << (429496729510h).count() << endl; return 0; } And the result is 429496729510 926648584