Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #91466

Re: Question

Newsgroups comp.lang.c
Date 2016-08-01 05:19 -0700
References <nnd8ue$nnp$2@dont-email.me> <nndoie$ip1$1@dont-email.me> <c2aa5c4d-cbf3-242a-f760-a654cf033d19@verizon.net>
Message-ID <e7444e89-94de-4db0-9992-9ec8976d6262@googlegroups.com> (permalink)
Subject Re: Question
From supercat@casperkitty.com

Show all headers | View raw


On Saturday, July 30, 2016 at 1:46:01 PM UTC-5, James R. Kuyper wrote:
> Tim Rentsch notified me by e-mail of a point I got wrong in that 
> explanation: while a character type can be used to alias a pointer type, 
> the reverse is not true. I even discussed this issue recently (with 
> supercat@casperkitty.com?), yet I still forgot about it. The reason in 
> this case isn't tiredness, but the fact that I find this asymmetry in 
> the anti-aliasing rules counter-intuitive. If an array of character type 
> is sufficiently long, correctly aligned (which is easier to arrange in 
> C2011 (using _Alignas()) than it was in older versions of C, and does 
> not contain a trap representation for the aliasing type, it seems to me 
> that you should be permitted to alias it - but the C standard only 
> allows aliasing in the other direction.

I've seen no reason to believe that the asymmetry was intended with
regard to character arrays, which can of course only be accessed with
(wait for it)...

   ** pointers to character types **

Any workable set of aliasing rules would be a fair bit longer than the
rules in C89, and the authors of the Standard almost certainly expected
that any quality compiler would recognize aliasing in the cases where it
is obvious.  While it would have been odd to omit the case where an
object of its exact type, I think their real interest was ensuring that
all compilers would recognize certain cases *beyond* those where it would
be obvious--those where pointers differ only by qualifiers or signedness,
or where things were accessed via character pointer.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Question DFS <nospam@dfs.com> - 2016-07-28 11:38 -0400
  Re: Question Melzzzzz <mel@zzzzz.com> - 2016-07-28 17:50 +0200
  Re: Question BartC <bc@freeuk.com> - 2016-07-28 17:49 +0100
    Re: Question Melzzzzz <mel@zzzzz.com> - 2016-07-28 18:52 +0200
    Re: Question Keith Thompson <kst-u@mib.org> - 2016-07-28 11:58 -0700
      Re: Question BartC <bc@freeuk.com> - 2016-07-28 20:57 +0100
  Re: Question "D. Aaron Sawyer" <aaron@110.net> - 2016-07-28 13:55 -0300
  Re: Question Barry Schwarz <schwarzb@dqel.com> - 2016-07-28 11:38 -0700
    Re: Question DFS <nospam@dfs.com> - 2016-07-28 15:20 -0400
    Re: Question Tim Rentsch <txr@alumni.caltech.edu> - 2016-07-30 09:24 -0700
  Re: Question Ian Collins <ian-news@hotmail.com> - 2016-07-29 07:23 +1200
  Re: Question James Kuyper <jameskuyper@verizon.net> - 2016-07-28 16:05 -0400
    Re: Question DFS <nospam@dfs.com> - 2016-07-29 10:14 -0400
    Re: Question "James R. Kuyper" <jameskuyper@verizon.net> - 2016-07-30 14:45 -0400
      Re: Question supercat@casperkitty.com - 2016-08-01 05:19 -0700
  Re: Question Tim Rentsch <txr@alumni.caltech.edu> - 2016-07-30 09:17 -0700

csiph-web