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


Groups > comp.std.c > #1832

Re: C11 6.3.2.3p7 Referenced Type

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Wojtek Lerch <wojtek_l@yahoo.ca>
Newsgroups comp.std.c
Subject Re: C11 6.3.2.3p7 Referenced Type
Date Thu, 10 Jan 2013 17:45:09 -0500
Lines 35
Message-ID <al8ujmFovdiU1@mid.individual.net> (permalink)
References <kc5v4n$ing$1@dont-email.me> <akppc6Favm8U1@mid.individual.net> <kfn1udxdbru.fsf@x-alumni2.alumni.caltech.edu> <akusqqFg0qhU1@mid.individual.net> <kcdj0t$g3v$1@dont-email.me> <akv3c8Fh7f0U1@mid.individual.net> <kcdpvu$adf$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net wmmmJs//bz0qRO+9J8G1eA2eVdbZ1JS6Mg6Ue8qsKzALz8klvRvnsD7rU3FXW9LsoG
Cancel-Lock sha1:X4UK7AW0c85ON+HAfOgZdTmU7CE=
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2
In-Reply-To <kcdpvu$adf$1@dont-email.me>
Xref csiph.com comp.std.c:1832

Show key headers only | View raw


On 07-Jan-13 1:29 AM, Shao Miller wrote:
> On 1/7/2013 00:07, Wojtek Lerch wrote:
>> In other words, does the standard guarantee that (char*)(int*)&x, if
>> defined, must be equal to (char*)&x?
>
> (I think you meant to ask about '(char*)(int*)&f' and '(char*)&f', and
> 'n' seems to have lost its relevance.)

Actually I meant to ask generally, without necessarily referring to the 
code above -- substitute "(char*)(int*)&lval" and "(char*)&lval"...  The 
only relevance of "n" was as a possible reference in "What if 
(int*)&lval points to some other object, let's call it 'n'?"

> I think that example has the same consideration as the last one.  If 'p'
> (or '(int*)&f' can point to an object than than 'f', then '(char*)p' can
> point to the lowest-addressed byte of that other object.  But
> '(float*)p' had better point to 'f' again.

Right.  But maybe it's a better example.

> One way this might happen is if, for the values of 'int *' and 'float
> *', pointers are simply indices, and '&f' means "the first float in the
> program" and '&n' means "the first int in the program".  'char *' and
> 'void *' (etc.) might have a greater range of meanings/values.

> Eep.  This would be scary.

Sure; this doesn't sound like a practical rule that a sane 
implementation might reasonably want to apply to all programs. 
Typically for C, unions and pointers to allocated memory mess things up. 
  But as far as I know, implementations aren't required to apply the 
same rules to all programs -- if a compiler only applies your 
index-based implementation of pointers only for programs that are simple 
enough to make it work, that's good enough as an example.

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


Thread

C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-04 02:08 -0500
  Re: C11 6.3.2.3p7 Referenced Type Keith Thompson <kst-u@mib.org> - 2013-01-04 08:09 -0800
    Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-04 12:25 -0500
    Re: C11 6.3.2.3p7 Referenced Type lawrence.jones@siemens.com - 2013-01-04 13:47 -0500
      Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-04 14:56 -0500
        Re: C11 6.3.2.3p7 Referenced Type lawrence.jones@siemens.com - 2013-01-04 17:10 -0500
          Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-04 20:34 -0500
  Re: C11 6.3.2.3p7 Referenced Type Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-04 23:45 -0500
    Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-05 02:07 -0500
      Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-05 02:16 -0500
    Re: C11 6.3.2.3p7 Referenced Type Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 17:25 -0800
      Re: C11 6.3.2.3p7 Referenced Type Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-06 22:13 -0500
        Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-06 23:30 -0500
          Re: C11 6.3.2.3p7 Referenced Type Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-07 00:07 -0500
            Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-07 01:29 -0500
              Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-07 02:18 -0500
              Re: C11 6.3.2.3p7 Referenced Type Wojtek Lerch <wojtek_l@yahoo.ca> - 2013-01-10 17:45 -0500
          Re: C11 6.3.2.3p7 Referenced Type Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 22:30 -0800
            Re: C11 6.3.2.3p7 Referenced Type Shao Miller <sha0.miller@gmail.com> - 2013-01-07 01:58 -0500
              Re: C11 6.3.2.3p7 Referenced Type Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 23:16 -0800
        Re: C11 6.3.2.3p7 Referenced Type Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-06 22:02 -0800

csiph-web