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++/65695] [4.9/5 Regression] NSDMI calling constexpr constructor with pointer-to-member is not a constant expression


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65695

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.9.2, 5.0

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
4.8 ICEs when using a pointer-to-data-member but not with
pointer-to-member-function, so here is a slightly less reduced version that
compiles with 4.8:

struct Foo;

struct Bar
{
    using MemberFuncT = int (Foo::*)();

    MemberFuncT h_;
    constexpr Bar(MemberFuncT h) : h_{h}
    {
    }
};

struct Foo
{
    int test()
    {
        return -1;
    }

    static constexpr Bar bar {&Foo::test};
};

constexpr Bar Foo::bar;


With 4.9.2:

c.cc:20:41: error: âconst Bar{&Foo::test}â is not a constant expression
     static constexpr Bar bar {&Foo::test};
                                         ^

With 5.0:

c.cc:20:41: error: âBar{&Foo::test}â is not a constant expression
     static constexpr Bar bar {&Foo::test};
                                         ^

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