Printf Core Dumps on A/UX

Ken Mandelberg km at emory.uucp
Sun Jan 8 00:40:03 AEST 1989


In article <8686 at alice.UUCP> debra at alice.UUCP () writes:
>In article <3568 at emory.uucp> km at emory.uucp (Ken Mandelberg) writes:
>}I consider this a bug:
>}
>}The printf on A/UX will core dump with a floating point
>}exception on extreme data. For example:
>}
>}		printf("%g\n", 0x7fffffff);
>}
>}will core dump on A/UX. On our BSD and other USG systems, this
>}prints "NaN", or some appropriate value (depending on the type
>}of internal floating point format).
>
>I don't consider this a bug. %g expects a double, i.e. 64 bits and
>you only give it an int, i.e. 32 bits.
>
>But maybe you have other examples...
>
>Paul.
>-- 
>------------------------------------------------------
>|debra at research.att.com   | uunet!research!debra     |
>------------------------------------------------------


I tried to submit this as compactly as possible. Note that
the core dump was a floating point exception not a bus
error, so it does show that printf can't handle some
exceptional data. However, here is another version of the
test program which gets the same exception on A/UX (and not
the other Unix systems):


main () {

	union {
		int hex[2];
		double d;
		} data;

	data.hex[0]=0x7fffffff;
	data.hex[1]=0xffffffff;

	printf("%g\n", data.d);
}
-- 
Ken Mandelberg      | km at mathcs.emory.edu          PREFERRED
Emory University    | {decvax,gatech}!emory!km     UUCP 
Dept of Math and CS | km at emory.bitnet              NON-DOMAIN BITNET  
Atlanta, GA 30322   | Phone: (404) 727-7963



More information about the Comp.unix.aux mailing list