passing address of floating-point parameter
Dale Worley
worley at compass.com
Sat Jun 15 00:39:21 AEST 1991
In article <64623 at bbn.BBN.COM> cjross at bbn.com (chris ross) writes:
foo (x, y)
float x, y;
{ }
Apparently, the Sun and MIPS compilers do not hide the fact that the
parameter in the first routine is actually on the stack as a (double).
Should they, or, as with va_arg, must the programmer explicitly take the
type promotion into account? Does ANSI specify the proper behavior?
According to ANSI C, x and y are passed in as doubles but must be
converted to floats upon entry. In particular, &x has type "pointer
to float". However, most K+R compilers promote x and y to doubles, so
&x has type "pointer to double". That is, not only is the value
passed in as a double, it remains a double once it is passed in.
Section 3.7.1 of the Rationale describes this situation, and notes it
as a "Quiet Change".
Dale Worley Compass, Inc. worley at compass.com
--
If there is a bedrock principle underlying the First Amendment,
it is that the Government may not prohibit the expression of an
idea simply because society finds the idea itself offensive or
disagreeable.
-- Justice William J. Brennan, expressing the opinion of the
Supreme Court in "Texas v. Johnson" (1989, flag-burning)
More information about the Comp.lang.c
mailing list