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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Or using constexpr, so no linking required to check the value:

struct CA {
  constexpr int foo() const { return 42; }
};

template <class T>
struct CB : CA { };

template <class T>
struct CC : CB<T> {
  constexpr int bar() const {
    const int m = CA::foo();
    return m;
  }

  constexpr int baz() const {
    const T m = CA::foo();
    return m;
  }
};

constexpr CC<double> c;

static_assert( c.bar() == 42, "" );


gcc-7-branch:

85060-2.cc: In member function 'constexpr int CC<T>::bar() const':
85060-2.cc:11:26: error: cannot call member function 'constexpr int CA::foo()
const' without object
     const int m = CA::foo();
                   ~~~~~~~^~
85060-2.cc: At global scope:
85060-2.cc:23:1: error: non-constant condition for static assertion
 static_assert( c.bar() == 42, "" );
 ^~~~~~~~~~~~~



trunk:

85060-2.cc:23:24: error: non-constant condition for static assertion
 static_assert( c.bar() == 42, "" );
                ~~~~~~~~^~~~~

Reply via email to