absolute pointer

Guy Harris guy at sun.uucp
Thu Nov 6 07:26:40 AEST 1986


> >		if ( shmaddr EQ (char *) -1 ) {
> 
> 
> The HP9000 Series 500 C compiler issues this warning whenever an
> integer constant other than 0 is used as a pointer.  Its intent
> is to flag statements that are machine dependent in code ported
> from other systems.

Unfortunately, the shared memory system calls in System V have a *really
poor* convention for indicating errors; they *should* have returned NULL,
but instead they return -1 cast to "char *".  The intent may have been to
make them "just like" system calls that return integral values, but this
doesn't buy you anything (other than being able to use the same user-mode
stub code for calls that return integral values and that use pointers, but
this only saves you a handful of bytes).

As such, while this code is flagging code that may be machine dependent, you
can't do anything about it (at least not while remaining compatible with the
SVID), so the warning is merely noise.  The compiler should NOT issue this
warning if -1 is being cast to a pointer.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)



More information about the Comp.lang.c mailing list