http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46134
Summary: constexpr vs. defaulted ctor
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
Changing std::chrono::duration's default constructor to "default" from an empty
body causes a new error.
Ie:
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index bbcb0ff..d346049 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -209,7 +209,7 @@ namespace std
static_assert(_Period::num > 0, "period must be positive");
// 20.8.3.1 construction / copy / destroy
- constexpr duration() { }
+ constexpr duration() = default;
template<typename _Rep2, typename = typename
enable_if<is_convertible<_Rep2, rep>::value
See attached pre-processed file for simple reproducer. Error message is:
In file included from
/mnt/share/src/gcc.git-constexpr/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc:22:0:
/mnt/share/src/gcc.git-constexpr/libstdc++-v3/testsuite/util/testsuite_common_types.h:
In member function ‘void
__gnu_test::constexpr_default_constructible::operator()()::_Concept::__constraint()
[with _Tp = std::chrono::duration<long int>]’:
/mnt/share/src/gcc.git-constexpr/libstdc++-v3/testsuite/util/testsuite_common_types.h:629:17:
instantiated from ‘void
__gnu_test::constexpr_default_constructible::operator()() [with _Tp =
std::chrono::duration<long int>]’
/mnt/share/src/gcc.git-constexpr/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc:27:48:
instantiated from here
/mnt/share/src/gcc.git-constexpr/libstdc++-v3/testsuite/util/testsuite_common_types.h:625:20:
error: uninitialized const ‘__v’ [-fpermissive]
/mnt/share/bld/gcc.git-constexpr/x86_64-unknown-linux-gnu/libstdc++-v3/include/chrono:201:14:
note: ‘const struct std::chrono::duration<long int>’ has no user-provided
default constructor
/mnt/share/bld/gcc.git-constexpr/x86_64-unknown-linux-gnu/libstdc++-v3/include/chrono:212:12:
note: constructor is not user-provided because it is explicitly defaulted in
the class body