From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,9ae5fbc502f16fef X-Google-Attributes: gid1164f8,public From: danpop@mail.cern.ch (Dan Pop) Subject: Re: Compiler flags of dubious utility. Date: 1995/12/15 Message-ID: #1/1 X-Deja-AN: 121941098 sender: news@news.cern.ch (USENET News System) x-nntp-posting-host: ues5.cern.ch references: <4akv6t$14i@topaz.sensor.com> <4akvcr$16q@topaz.sensor.com> <4aqnhp$dpn@usenet.pa.dec.com> organization: CERN European Lab for Particle Physics newsgroups: comp.sys.dec 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 > 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