0
#include <iostream>
using namespace std;
class A
{
    public:
    void g() noexcept {}
    void f() noexcept( noexcept( g() )) {};
};

A a;
int main()
{
    cout<<noexcept(a.f())<<endl;
    return 0;
}

When I try to compile this program with gcc 5.1.1, I got an error -

Error: cannot call member function without object ‘void A::g()’

|| void f() noexcept( noexcept( g() )) {};

However, in clang++3.6 this can be compiled and the output is 1

Is there any way to resolve this problem?

Community
  • 1
  • 1
lz96
  • 2,816
  • 2
  • 28
  • 46
  • http://stackoverflow.com/questions/18878029/noexcept-depend-on-noexcept-of-a-member-function – Xiaotian Pei Jun 07 '15 at 07:40
  • @XiaotianPei According to ISO/IEC 14882:2011 5.3.7.3, `noexcept` operator should contain _a potentially evaluated **call** to a function_, and an example on cppreference also includes `noexcept(no_throw())`. – lz96 Jun 07 '15 at 07:50

0 Answers0