[Bug c++/92495] spaceship operator requires public member

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 13 13:47:00 GMT 2019


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-11-13
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Please provide a testcase that actually exhibits the bug, rather than
commenting out the thing that causes the problem. You're also missing the other
info requested by https://gcc.gnu.org/bugs such as output of 'gcc -v' and the
command-line options used.

Confirmed on trunk, for this test, with -std=gnu++2a:


#include <compare>

template<auto V>
struct A {};

struct B {
    inline constexpr auto operator<=>(const B& rhs) const = default;
private:
    int value; // why must this member be public?
};

int main() {
    A<B{}> t;
}



92495.cc: In function 'int main()':
92495.cc:13:10: error: 'B' is not a valid type for a template non-type
parameter because it is not structural
   13 |     A<B{}> t;
      |          ^
92495.cc:9:9: note: 'B::value' is not public
    9 |     int value; // why must this member be public?
      |         ^~~~~
92495.cc:13:12: warning: unused variable 't' [-Wunused-variable]
   13 |     A<B{}> t;
      |            ^


More information about the Gcc-bugs mailing list