[net.lang.c] absolute pointer

drears@ardec.ARPA (FSAC) (10/29/86)

     We are running HP-UP UNIX on a Hewlett-Packard System 9050. THe
HP-UP is SYSV look alike with shared memory operations.  I am trying to
compile a program that allows users to talk with each other.  This
program is similiar to talk except that is uses shared memory.  It
compiles and works under a AT&T SYS5 release 2.  However when I compile
it under hp-UNIX I get the following error messages:

rap.c, line 310: warning: absolute pointer used
rap.c, line 369: warning: absolute pointer used

Lines 310 & 369 are the exact same and look like this:

		if ( shmaddr EQ (char *) -1 ) {


   Can anyone shed some light on what is meant by an absolute
pointer.  I am assuming it doesn't like the cast but I am not sure.
Incidently the "EQ" is defined as "==".


Dennis

henry@utzoo.UUCP (Henry Spencer) (10/31/86)

> rap.c, line 310: warning: absolute pointer used
> 
> 		if ( shmaddr EQ (char *) -1 ) {

The compiler is trying to warn you, in a somewhat cryptic way, that casting
any integer except the constant 0 into a pointer is a machine-dependent,
unportable, and dangerous operation.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry

levy@ttrdc.UUCP (Daniel R. Levy) (11/02/86)

In article <7267@utzoo.UUCP>, henry@utzoo.UUCP (Henry Spencer) writes:
>> rap.c, line 310: warning: absolute pointer used
>> 
>> 		if ( shmaddr EQ (char *) -1 ) {
>
>The compiler is trying to warn you, in a somewhat cryptic way, that casting
>any integer except the constant 0 into a pointer is a machine-dependent,
>unportable, and dangerous operation.
>-- 
>				Henry Spencer @ U of Toronto Zoology
>				{allegra,ihnp4,decvax,pyramid}!utzoo!henry

However, in SysV the shmat(2) call returns (char *) -1 in case of error.  I'll
bet a doughnut that this is where shmaddr is coming from.

Is anyone aware of any computer where this would not work as intended
(thus, couldn't support full SysV)?  It could be argued that NULL (i.e., 0,
with its already agreed-upon special-caseness) would have been better (more
portable?) but it's too late now and I've never heard where it hurt anyone
either.
-- 
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
	   go for it!  			allegra,ulysses,vax135}!ttrdc!levy

kah@hpfclq.HP.COM (Kathy Harris) (11/03/86)

>rap.c, line 310: warning: absolute pointer used

>Lines 310 & 369 are the exact same and look like this:

>		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.

Kathy Harris
Hewlett Packard, Systems Software Operation
{hplabs, ihnp4}!hpfcla!kah

guy@sun.uucp (Guy Harris) (11/06/86)

> >		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@sun.com (or guy@sun.arpa)