public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Spaceship-operator: why the data-members must be public / triggers ICE
@ 2019-11-13  9:24 Klaus Doldinger
  2019-11-13 10:35 ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Klaus Doldinger @ 2019-11-13  9:24 UTC (permalink / raw)
  To: gcc-help

Hi all,

in the follwing example

#include <compare> // omitting trigger ICE

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;
}

why must the member value be public?

Side note: if I omit #include <compare> it triggers an ICE.

Compiler: gcc-trunk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spaceship-operator: why the data-members must be public / triggers ICE
  2019-11-13  9:24 Spaceship-operator: why the data-members must be public / triggers ICE Klaus Doldinger
@ 2019-11-13 10:35 ` Jonathan Wakely
  2019-11-13 11:43   ` Klaus Doldinger
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2019-11-13 10:35 UTC (permalink / raw)
  To: Klaus Doldinger; +Cc: gcc-help

On Wed, 13 Nov 2019 at 09:24, Klaus Doldinger
<klaus.doldinger64@gmail.com> wrote:
>
> Hi all,
>
> in the follwing example
>
> #include <compare> // omitting trigger ICE
>
> 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;
> }
>
> why must the member value be public?

Looks like a bug, please report it to bugzilla.

> Side note: if I omit #include <compare> it triggers an ICE.

And please report that to bugzilla too, as a second bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spaceship-operator: why the data-members must be public / triggers ICE
  2019-11-13 10:35 ` Jonathan Wakely
@ 2019-11-13 11:43   ` Klaus Doldinger
  2019-11-13 12:47     ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Klaus Doldinger @ 2019-11-13 11:43 UTC (permalink / raw)
  To: gcc-help



Am 13.11.19 um 11:35 schrieb Jonathan Wakely:
> On Wed, 13 Nov 2019 at 09:24, Klaus Doldinger
> <klaus.doldinger64@gmail.com> wrote:
>>
>> Hi all,
>>
>> in the follwing example
>>
>> #include <compare> // omitting trigger ICE
>>
>> 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;
>> }
>>
>> why must the member value be public?
> 
> Looks like a bug, please report it to bugzilla.

Done.

> 
>> Side note: if I omit #include <compare> it triggers an ICE.
> 
> And please report that to bugzilla too, as a second bug.
> 

Done.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spaceship-operator: why the data-members must be public / triggers ICE
  2019-11-13 11:43   ` Klaus Doldinger
@ 2019-11-13 12:47     ` Jonathan Wakely
  2019-12-20  8:39       ` Klaus Doldinger
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2019-11-13 12:47 UTC (permalink / raw)
  To: Klaus Doldinger; +Cc: gcc-help

On Wed, 13 Nov 2019 at 11:43, Klaus Doldinger
<klaus.doldinger64@gmail.com> wrote:
>
>
>
> Am 13.11.19 um 11:35 schrieb Jonathan Wakely:
> > On Wed, 13 Nov 2019 at 09:24, Klaus Doldinger
> > <klaus.doldinger64@gmail.com> wrote:
> >>
> >> Hi all,
> >>
> >> in the follwing example
> >>
> >> #include <compare> // omitting trigger ICE
> >>
> >> 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;
> >> }
> >>
> >> why must the member value be public?
> >
> > Looks like a bug, please report it to bugzilla.
>
> Done.
>
> >
> >> Side note: if I omit #include <compare> it triggers an ICE.
> >
> > And please report that to bugzilla too, as a second bug.
> >
>
> Done.

Thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spaceship-operator: why the data-members must be public / triggers ICE
  2019-11-13 12:47     ` Jonathan Wakely
@ 2019-12-20  8:39       ` Klaus Doldinger
  2019-12-20 10:25         ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Klaus Doldinger @ 2019-12-20  8:39 UTC (permalink / raw)
  To: gcc-help


Am 13.11.19 um 13:47 schrieb Jonathan Wakely:
> On Wed, 13 Nov 2019 at 11:43, Klaus Doldinger
> <klaus.doldinger64@gmail.com> wrote:
>>
>>
>>
>> Am 13.11.19 um 11:35 schrieb Jonathan Wakely:
>>> On Wed, 13 Nov 2019 at 09:24, Klaus Doldinger
>>> <klaus.doldinger64@gmail.com> wrote:
>>>>
>>>> Hi all,
>>>>
>>>> in the follwing example
>>>>
>>>> #include <compare> // omitting trigger ICE
>>>>
>>>> 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;
>>>> }
>>>>
>>>> why must the member value be public?
>>>
>>> Looks like a bug, please report it to bugzilla.
>>

Ok, we found this not to be a bug.

But, how do I write a class to use as NTTP with private members?

I'm a bit confused about:

https://en.cppreference.com/w/cpp/language/template_parameters

Here string structural equality does not require all public members.
It must be literal and the members must be structural revursively.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spaceship-operator: why the data-members must be public / triggers ICE
  2019-12-20  8:39       ` Klaus Doldinger
@ 2019-12-20 10:25         ` Jonathan Wakely
  2019-12-20 10:30           ` Klaus Doldinger
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2019-12-20 10:25 UTC (permalink / raw)
  To: Klaus Doldinger; +Cc: gcc-help

On Fri, 20 Dec 2019, 08:39 Klaus Doldinger, <klaus.doldinger64@gmail.com> wrote:
>
>
> Am 13.11.19 um 13:47 schrieb Jonathan Wakely:
> > On Wed, 13 Nov 2019 at 11:43, Klaus Doldinger
> > <klaus.doldinger64@gmail.com> wrote:
> >>
> >>
> >>
> >> Am 13.11.19 um 11:35 schrieb Jonathan Wakely:
> >>> On Wed, 13 Nov 2019 at 09:24, Klaus Doldinger
> >>> <klaus.doldinger64@gmail.com> wrote:
> >>>>
> >>>> Hi all,
> >>>>
> >>>> in the follwing example
> >>>>
> >>>> #include <compare> // omitting trigger ICE
> >>>>
> >>>> 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;
> >>>> }
> >>>>
> >>>> why must the member value be public?
> >>>
> >>> Looks like a bug, please report it to bugzilla.
> >>
>
> Ok, we found this not to be a bug.
>
> But, how do I write a class to use as NTTP with private members?


You don't.

>
> I'm a bit confused about:
>
> https://en.cppreference.com/w/cpp/language/template_parameters
>
> Here string structural equality does not require all public members.
> It must be literal and the members must be structural revursively.


That page hasn't been edited in more than six months, it doesn't
describe the current status of the C++20 draft.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spaceship-operator: why the data-members must be public / triggers ICE
  2019-12-20 10:25         ` Jonathan Wakely
@ 2019-12-20 10:30           ` Klaus Doldinger
  2019-12-20 10:40             ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: Klaus Doldinger @ 2019-12-20 10:30 UTC (permalink / raw)
  To: gcc-help



Am 20.12.19 um 11:25 schrieb Jonathan Wakely:
> On Fri, 20 Dec 2019, 08:39 Klaus Doldinger, <klaus.doldinger64@gmail.com> wrote:
>>
>>
>> Am 13.11.19 um 13:47 schrieb Jonathan Wakely:
>>> On Wed, 13 Nov 2019 at 11:43, Klaus Doldinger
>>> <klaus.doldinger64@gmail.com> wrote:
>>>>
>>>>
>>>>
>>>> Am 13.11.19 um 11:35 schrieb Jonathan Wakely:
>>>>> On Wed, 13 Nov 2019 at 09:24, Klaus Doldinger
>>>>> <klaus.doldinger64@gmail.com> wrote:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> in the follwing example
>>>>>>
>>>>>> #include <compare> // omitting trigger ICE
>>>>>>
>>>>>> 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;
>>>>>> }
>>>>>>
>>>>>> why must the member value be public?
>>>>>
>>>>> Looks like a bug, please report it to bugzilla.
>>>>
>>
>> Ok, we found this not to be a bug.
>>
>> But, how do I write a class to use as NTTP with private members?
> 
> 
> You don't.

Well, that is an extremly hard restriction, I think.
Are there reasons for that?

>>
>> I'm a bit confused about:
>>
>> https://en.cppreference.com/w/cpp/language/template_parameters
>>
>> Here string structural equality does not require all public members.
>> It must be literal and the members must be structural revursively.
> 
> 
> That page hasn't been edited in more than six months, it doesn't
> describe the current status of the C++20 draft.

Ok, thanks for clearifying that.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Spaceship-operator: why the data-members must be public / triggers ICE
  2019-12-20 10:30           ` Klaus Doldinger
@ 2019-12-20 10:40             ` Jonathan Wakely
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Wakely @ 2019-12-20 10:40 UTC (permalink / raw)
  To: Klaus Doldinger; +Cc: gcc-help

On Fri, 20 Dec 2019 at 10:30, Klaus Doldinger
<klaus.doldinger64@gmail.com> wrote:
> Am 20.12.19 um 11:25 schrieb Jonathan Wakely:
> > On Fri, 20 Dec 2019, 08:39 Klaus Doldinger, <klaus.doldinger64@gmail.com> wrote:
> >> But, how do I write a class to use as NTTP with private members?
> >
> >
> > You don't.
>
> Well, that is an extremly hard restriction, I think.
> Are there reasons for that?

Several. In short, they don't work very well and introduce
inconsistencies and warts to the language.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1837r0.html
covers some of it.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-12-20 10:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-13  9:24 Spaceship-operator: why the data-members must be public / triggers ICE Klaus Doldinger
2019-11-13 10:35 ` Jonathan Wakely
2019-11-13 11:43   ` Klaus Doldinger
2019-11-13 12:47     ` Jonathan Wakely
2019-12-20  8:39       ` Klaus Doldinger
2019-12-20 10:25         ` Jonathan Wakely
2019-12-20 10:30           ` Klaus Doldinger
2019-12-20 10:40             ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).