[PATCH] Fixes sentinel warnings on GCC4

Stuart D. Gathman stuart at bmsi.com
Tue Dec 6 17:07:50 EST 2005


On Tue, 6 Dec 2005, Chris Shoemaker wrote:

> > A pointer to a char is the same size as a pointer to an int and is the
> > same size as a pointer to void.  
> 
> This is not generally true for typed null pointers.  Implementations
> are free to use different representations for null pointers of
> different types.  This has in fact been done.  Using the null-pointer
> of the wrong type is not portable.  This is why David was right about
> (void*) being better than (char*) on the sentinel.

Pointers are generally the same size on byte-addressable machines like
i386 and ppc.  You run into trouble with old architectures and embedded
RISC.  

<old-timer>
My favorite old architecture was the DEC-20.  It had 36-bit words. C types:

char	9 bits
short	18 bits
int	36 bits
long	72 bits
float	36 bits
double	72 bits
char *	36 bits
short *	36 bits
int *	18 bits
long *	18 bits
int **	36 bits
char **	36 bits
...

Most pointers were word pointers.  Char and short pointers used a special
subfield pointer extension that had its own load/store/inc/dec instructions.

I find it useful to ask myself whether the code would run properly on that
system when considering a portablity question.  Not that a DEC-20 would
be all that useful today.  2^18 * 36 bits = 2Meg * 9-bits byte addressable RAM.
The system I used in college had 256K words = 1M * 9-bit RAM.  If you
were lucky enough to be allowed to use the console, it had a memory mapped
graphics display, and the extended pointer format could also address individual
pixels!  The display was featured in my favorite "Flatland" fiction:
	_The_Planiverse_
	http://www.amazon.com/gp/product/0387989161/
</old-timer>

More relevant today are graphics processors (which I guess is a type of
embedded), which often have varying pointer sizes, including pointers
to bits and nybbles, to optimize bit pixel operations.

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
    Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.



More information about the gnucash-devel mailing list