flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Need help in C (Pointers and References)

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 30 Dec 2012, 23:28
revolution,

NULL is (as of C1X April 2011 draft) an implementation-defined null pointer constant. OTOH, chapter "6.3.2.3 Pointers" clause 3 says that "An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant."

There are some other references to void * type. For example, chapter "6.2.5 Types" clause 28 tells that "A pointer to void shall have the same representation and alignment requirements as a pointer to a character type."

Caveat emptor. Wink
Post 30 Dec 2012, 23:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 31 Dec 2012, 00:05
baldr wrote:
NULL is ... an implementation-defined null pointer constant.
That sounds more like the reality. I couldn't see any reason why NULL has to be always zero. It is only by convention that people expect it to be zero. And I think that to be a genuine NULL it should exist outside of the number space completely and not have any numeric value.
baldr wrote:
Caveat emptor. Wink
Indeed.
Post 31 Dec 2012, 00:05
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 31 Dec 2012, 03:13
revolution wrote:
And I think that to be a genuine NULL it should exist outside of the number space completely and not have any numeric value.


What would its value be then?
Post 31 Dec 2012, 03:13
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 31 Dec 2012, 04:20
typedef wrote:
revolution wrote:
And I think that to be a genuine NULL it should exist outside of the number space completely and not have any numeric value.


What would its value be then?
If you are asking how would it be represented then that would be implementation defined. A possible method is to associate an extra bit with each pointer that indicates whether it is null or not.
Post 31 Dec 2012, 04:20
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.