[Bug libstdc++/58850] New: Conversion error in chrono

galens at capaccess dot org gcc-bugzilla@gcc.gnu.org
Wed Oct 23 01:30:00 GMT 2013


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<long long,std::ratio<36*24*36525,1>>)
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)

<output>
Years: 12067
seconds:     380805559200
Minutes * 60:     123107521440
Minutes:     2051792024
Seconds / 60:     6346759320
</output>

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++" )



More information about the Gcc-bugs mailing list