Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!compass!worley From: worley@compass.com (Dale Worley) Newsgroups: comp.lang.c Subject: Re: passing address of floating-point parameter Message-ID: Date: 14 Jun 91 14:39:21 GMT References: <64623@bbn.BBN.COM> Sender: root@compass.com Distribution: world Organization: Compass, Inc., Wakefield, MA, U.S.A. Lines: 27 In-reply-to: cjross@bbn.com's message of 12 Jun 91 02:00:42 GMT In article <64623@bbn.BBN.COM> cjross@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@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)