This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70521] New: [C++14] nonempty constexpr noexcept constructor rejected


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]