POV-Ray : Newsgroups : povray.off-topic : Quick C language-lawyer question... : Quick C language-lawyer question... Server Time
5 Sep 2024 11:26:29 EDT (-0400)
  Quick C language-lawyer question...  
From: Darren New
Date: 30 Jul 2009 16:14:17
Message: <4a71ff19$1@news.povray.org>
By my reading, neither C nor C++ guarantee the following:

union {
   long x;
   char* y;
} xyz;
xyz.y = NULL;
printf("%ld\n", xyz.x);

Neither C nor C++ guarantees that'll be zero (assuming 
sizeof(char*)==sizeof(long)).  In other words, neither guarantees that the 
bit pattern in memory for NULL is actually all zeros, right?

So using memset() to clear a structure to 0 that contains pointers isn't 
guaranteed to be portable to something like the AT&T 3B2, where NULL != 0x0 
in memory?

I looked, but all I found were references to "null pointer value", and not 
any bit patterns.

-- 
   Darren New, San Diego CA, USA (PST)
   "We'd like you to back-port all the changes in 2.0
    back to version 1.0."
   "We've done that already. We call it 2.0."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.