Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: What is the value after operator '!'? |
| Date | 2015-10-26 17:15 -0700 |
| Organization | None to speak of |
| Message-ID | <lnegghdv56.fsf@kst-u.example.com> (permalink) |
| References | (3 earlier) <87si4xjzui.fsf@bsb.me.uk> <ln8u6pfqup.fsf@kst-u.example.com> <d0132578-984d-47b0-995e-a3d2aebeeaaf@googlegroups.com> <n0m2bp$r67$1@speranza.aioe.org> <109a24dd-df07-42bb-989d-a92425eb0164@googlegroups.com> |
supercat@casperkitty.com writes:
> On Monday, October 26, 2015 at 3:27:52 PM UTC-5, glen herrmannsfeldt wrote:
>> supercat wrote:
>> > In a system where (char*)x would yield a pointer to physical address x,
>> > and where physical address zero was valid, but where (char*)0 [i.e. NULL]
>> > was represented by a pointer with some physical address other than zero,
>> > would there be any way of writing a pointer constant equal to physical
>> > address zero?
>>
>> You only ever need to do that in very specific, system dependent cases.
>
> On the vast majority of systems NULL is represented by all-bits-zero, and
> pointers have the same representation as their corresponding intptr_t
> values, making the issue largely moot.
>
> On the other hand, it's not terribly uncommon for systems to have something
> useful at address zero which code needs to access. If one needs to fetch
> something from address zero and not have the compiler decide it should
> eliminate the code since it's dereferencing a null pointer, what would be
> the most reliable way to do that?
Either do it in some compiler-specific way, or convert a non-constant
integer with the value 0 to a pointer type. The latter isn't guaranteed
to work, but "The mapping functions for converting a pointer to an
integer or an integer to a pointer are intended to be consistent with
the addressing structure of the execution environment." (N1570 6.3.2.3,
footnote).
[...]
--
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
What is the value after operator '!'? fl <rxjwg98@gmail.com> - 2015-10-26 06:21 -0700
Re: What is the value after operator '!'? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-10-26 09:29 -0400
Re: What is the value after operator '!'? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-26 13:42 +0000
Re: What is the value after operator '!'? supercat@casperkitty.com - 2015-10-26 07:53 -0700
Re: What is the value after operator '!'? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-26 17:37 +0000
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-26 11:05 -0700
Re: What is the value after operator '!'? supercat@casperkitty.com - 2015-10-26 11:38 -0700
Re: What is the value after operator '!'? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-10-26 20:27 +0000
Re: What is the value after operator '!'? supercat@casperkitty.com - 2015-10-26 14:16 -0700
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-26 17:15 -0700
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-26 17:12 -0700
Re: What is the value after operator '!'? Ian Collins <ian-news@hotmail.com> - 2015-10-27 10:27 +1300
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-26 15:15 -0700
Re: What is the value after operator '!'? supercat@casperkitty.com - 2015-10-26 16:16 -0700
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-27 08:39 -0700
Re: What is the value after operator '!'? Richard Heathfield <rjh@cpax.org.uk> - 2015-10-26 14:04 +0000
Re: What is the value after operator '!'? Geoff <geoff@invalid.invalid> - 2015-10-26 09:50 -0700
csiph-web