[Bug libstdc++/54025] New: atomic<chrono::duration> won't compile: chrono::duration::duration() is not C++11 compliant

chip at pobox dot com gcc-bugzilla@gcc.gnu.org
Thu Jul 19 02:55:00 GMT 2012


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

             Bug #: 54025
           Summary: atomic<chrono::duration> won't compile:
                    chrono::duration::duration() is not C++11 compliant
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: chip@pobox.com


Attempting to compile atomic<duration> fails, because the duration default
constructor is not " = default" as required by the standard, but instead
explicitly initializes its representation.  Here is what libstdc++ says:

    constexpr duration() : __r() { }

but here is what the standard says should be there, and if I make the change,
compilation succeeds:

    constexpr duration() = default;

Test source:

#include <atomic>
#include <chrono>
using namespace std;
using namespace chrono;
int main() {
    atomic<duration<long, micro>> dur;
}

Error before patch:

/usr/include/c++/4.7/atomic: In instantiation of ‘struct
std::atomic<std::chrono::duration<long int, std::ratio<1ll, 1000000ll> > >’:
atdur.cc:6:35:   required from here
/usr/include/c++/4.7/atomic:160:7: error: function ‘std::atomic<_Tp>::atomic()
[with _Tp = std::chrono::duration<long int, std::ratio<1ll, 1000000ll> >]’
defaulted on its first declaration with an exception-specification that differs
from the implicit declaration ‘constexpr std::atomic<std::chrono::duration<long
int, std::ratio<1ll, 1000000ll> > >::atomic()’



More information about the Gcc-bugs mailing list