From: Andre Majorel (amajorel_at_teaser.fr)
Date: 2003-08-27 12:05:15
On 2003-08-27 07:20 +0200, Groepaz wrote: > mmmmh i see another funny problem here...what if i really want to > assign 0 (and _not_ NULL, whatever bitpattern it is) because i want to > use the pointer to access the memory at location 0? > > something like > > int i; > char *p; > > i=0; > p=(char*)i; > > comes to mind, but would that even work as intended? Yes. > (the compiler might optimize out the helper variable, and then again > convert the zero to NULL when assigning to the pointer) A compiler that would represent the null pointer with another bit pattern that all zeroes and still do that would be non-conformant. With respect to pointers, the integer constant 0 (i.e. the token 0 in the source code) is special. The integer value (i.e. an int which compares equal to 0) is not. > OR is it so that *(char*)NULL is defined to access memory at location zero? > (which would again raise the question how to access the memory at that > certain bitpattern defined as NULL :=P) I'm not sure I understand your question but... The null pointer might not be a valid address at all. On some architectures, attempting to dereference a null pointer might cause not just a segfault but a CPU-level exception (bus error or something like that). -- André Majorel <amajorel_at_teaser.fr> http://www.teaser.fr/~amajorel/ ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2003-08-27 12:07:47 CEST