noexcept : different behavior on clang++ and g++ [duplicate]

This question already has an answer here:

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

A a;
int main()
    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?

Source: gcc

Leave a Reply