Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #128165
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Does simple inheritance break strict-aliasing rule |
| Date | 2018-03-21 11:48 -0700 |
| Organization | None to speak of |
| Message-ID | <lno9jhp8mj.fsf@kst-u.example.com> (permalink) |
| References | <p8tbjk$mku$1@dont-email.me> <87h8p9tofh.fsf@bsb.me.uk> <f8e43b88-b58c-4962-a582-282992b5de58@googlegroups.com> <lnwoy5pcqa.fsf@kst-u.example.com> <dc6a4f94-5848-4361-806f-1cb901c24214@googlegroups.com> |
supercat@casperkitty.com writes:
> On Wednesday, March 21, 2018 at 12:20:25 PM UTC-5, Keith Thompson wrote:
>> supercat@casperkitty.com writes:
>> > A literal reading of the rules would indicate that given:
>> >
>> > struct foo {int x; } *p;
>> >
>> > the lvalue "p->x" has type "int". As such, it may be used to access any
>> > object whose type is simply "int", but may not be used to access any object
>> > of type "struct foo".
>>
>> Of course p->x is of type int.
>>
>> > The rules would make a lot of sense if "p->x" were regarded for purposes of
>> > 6.5p7 as an lvalue of type "struct foo"
>>
>> No, it would make no sense at all to treat p->x as an lvalue of type
>> struct foo. Would you want this to be legal?
>>
>> struct foo {int x; } *p;
>> struct foo obj;
>> // assume reasonable initializations
>> p->x = obj;
>
> For purposes *other than 6.5p7* the normal meanings would apply.
>
>> If p->x is regarded as an lvalue of type struct foo, why would that last
>> assignment not be legal?
>
> Because portions of the Standard other than 6.5p7 would forbid it.
>
> I'm only suggesting the alternate meaning *for purposes of 6.5p7*; an
> alternative way of saying the same thing would be to reword 6.7p7 to refer
> to something other than the "type" of the lvalue.
It's conceivable that you could construct a consistent description given
this change. But I'm having difficulty expressing just how absurd your
idea is. p->x is not of type struct foo, it's of type int. Pretending
for any purpose that it's of type struct foo is just silly.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Does simple inheritance break strict-aliasing rule pozz <pozzugno@gmail.com> - 2018-03-21 11:19 +0100
Re: Does simple inheritance break strict-aliasing rule Thiago Adams <thiago.adams@gmail.com> - 2018-03-21 05:37 -0700
Re: Does simple inheritance break strict-aliasing rule Steven Petruzzellis <frelwizzen@gmail.com> - 2018-03-21 07:02 -0700
Re: Does simple inheritance break strict-aliasing rule James Kuyper <jameskuyper@verizon.net> - 2018-03-21 10:31 -0400
Re: Does simple inheritance break strict-aliasing rule supercat@casperkitty.com - 2018-03-21 09:38 -0700
Re: Does simple inheritance break strict-aliasing rule Nick Bowler <nbowler@draconx.ca> - 2018-03-21 14:46 +0000
Re: Does simple inheritance break strict-aliasing rule supercat@casperkitty.com - 2018-03-21 08:18 -0700
Re: Does simple inheritance break strict-aliasing rule Steven Petruzzellis <frelwizzen@gmail.com> - 2018-03-21 23:23 -0700
Re: Does simple inheritance break strict-aliasing rule Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-03-21 15:53 +0000
Re: Does simple inheritance break strict-aliasing rule supercat@casperkitty.com - 2018-03-21 09:30 -0700
Re: Does simple inheritance break strict-aliasing rule Keith Thompson <kst-u@mib.org> - 2018-03-21 10:20 -0700
Re: Does simple inheritance break strict-aliasing rule supercat@casperkitty.com - 2018-03-21 10:54 -0700
Re: Does simple inheritance break strict-aliasing rule Keith Thompson <kst-u@mib.org> - 2018-03-21 11:48 -0700
Re: Does simple inheritance break strict-aliasing rule supercat@casperkitty.com - 2018-03-21 14:28 -0700
Re: Does simple inheritance break strict-aliasing rule Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-03-21 21:39 +0000
csiph-web