Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: danpop@mail.cern.ch (Dan Pop)
Subject: Re: Compiler flags of dubious utility.
Date: 1995/12/15	[thread overview]
Message-ID: <danpop.819059509@rscernix> (raw)
In-Reply-To: 4aqnhp$dpn@usenet.pa.dec.com

In <4aqnhp$dpn@usenet.pa.dec.com> mogul@pa.dec.com (Jeffrey Mogul) writes:

>Here's a correct example of mixing 32 and 64 bit pointers:

It is, however, a bad example of using fprintf :-)

>    #include <stdio.h>
>    main()
>    {
>	    char *format1 = "sizeof(format1) = %d\n";
>    #pragma pointer_size (short)
>	    char *format2 = "sizeof(format2) = %d\n";
>    
>	    fprintf(stdout, format1, sizeof(format1));
>	    fprintf(stdout, format2, sizeof(format2));
>    }

%d expects an int.  sizeof returns a size_t value, which on OSF/1 is an
unsigned long.  The result is undefined behaviour.  There are two 
independent reasons which make the code to work as intended on DEC OSF/1
(32-bit int's are promoted to 64 bits when they are passed as function
arguments and OSF/1 is little endian, anyway).  But this is not enough
to make it correct code.

Dan
--
Dan Pop
CERN, CN Division
Email: danpop@mail.cern.ch 
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



  reply	other threads:[~1995-12-15  5:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-12-12  5:00 Compiler flags of dubious utility Ron Natalie
1995-12-12  5:00 ` Dan Pop
1995-12-12  5:00   ` Ron Natalie
1995-12-12  5:00     ` Ron Natalie
1995-12-15  5:00       ` Jeffrey Mogul
1995-12-15  5:00         ` Dan Pop [this message]
1995-12-15  5:00         ` Dan Pop
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox