From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5990 invoked by alias); 23 Oct 2013 01:30:26 -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 5961 invoked by uid 48); 23 Oct 2013 01:30:23 -0000 From: "galens at capaccess dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/58850] New: Conversion error in chrono Date: Wed, 23 Oct 2013 01:30: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: galens at capaccess dot org 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 attachments.created 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: 2013-10/txt/msg01645.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58850 Bug ID: 58850 Summary: Conversion error in chrono Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: galens at capaccess dot org Created attachment 31077 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31077&action=edit minimal_test_case.cpp I noticed an odd error when using chrono::duration_cast<> to cast a home-made Years object (typedef of chrono::duration>) to chrono::minutes and chrono::seconds the conversion to seconds works fine; however, when converting this value into minutes, I found a (presumably overflow) error. I've attached a small .cpp that creates a Years object of 12067, and converts it to seconds and minutes. The following is the output I get: (and yes, I know that a year isn't actually 365.25 days; the rounding is fine for my purposes) Years: 12067 seconds: 380805559200 Minutes * 60: 123107521440 Minutes: 2051792024 Seconds / 60: 6346759320 Platform: Fedora 19 3.11.2 x86_64 GCC 3.9.0 ( locally built, but the only difference from a normal build was "../configure --enable-languages=c++" )