[Bug c++/127096] [13/14/15/16/17 Regression] Wrong decltype((S::x)) in const member function of unrelated class A

ppalka at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Aug 27 14:09:01 GMT 2026


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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |ppalka at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=105637
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2026-08-27

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r13-984 "c++: cv-quals of dummy obj for non-dep memfn call
[PR105637]".
We need to be mindful of dependent bases too:

struct S { int x; };

struct A { };

template<class T>
struct B : T {
  void g() const {
    static_assert(__is_same(decltype((S::x)), const int&));
  }
};

template struct B<S>;  // OK
template struct B<A>;  // error: static assertion failed


More information about the Gcc-bugs mailing list