[Bug c++/70521] New: [C++14] nonempty constexpr noexcept constructor rejected
meiomorphism at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Apr 3 21:30:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70521
Bug ID: 70521
Summary: [C++14] nonempty constexpr noexcept constructor
rejected
Product: gcc
Version: 5.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: meiomorphism at gmail dot com
Target Milestone: ---
Created attachment 38170
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38170&action=edit
test case
The following code is rejected by gcc 5.2.1.
====
#include <cassert>
struct A
{
int v;
constexpr A() noexcept : v(3) { assert(v != 0); }
};
int main() { }
====
====
$ g++ -std=c++14 err.cpp
err.cpp: In constructor ‘constexpr A::A()’:
err.cpp:6:53: error: member ‘A::v’ must be initialized by mem-initializer in
‘constexpr’ constructor
constexpr A() noexcept : v(3) { assert(v != 0); }
^
err.cpp:5:9: note: declared here
int v;
^
====
The mem-initializer in question is clearly present. clang 3.6.2 and 3.7.0
accept this code without diagnostics.
Removing any of "constexpr", "noexcept", or the "assert()" call results in the
code being accepted.
More information about the Gcc-bugs
mailing list