Path: utzoo!yunexus!ists!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!rice!uw-beaver!Teknowledge.COM!unix!hplabs!hp-ses!hpcuhb!hpcllla!hpclisp!shankar From: shankar@hpclisp.HP.COM (Shankar Unni) Newsgroups: comp.lang.c++ Subject: float parameters in C++; type rewriting? Message-ID: <1000037@hpclisp.HP.COM> Date: 17 Nov 89 23:06:23 GMT Article-I.D.: hpclisp.1000037 Organization: Hewlett-Packard Calif. Language Lab Lines: 29 This is about the handling of formal parameters of type "float" in C++. The 2.0 language spec seems to imply that these floats should be treated as floats, and that any parameter passed to such functions should be passed as a float. In actuality, what seems to be happening is that in the generated K&R C code (the default), an old-style definition is put out (causing the "float" parameter to be treated by the compiler as a double), and, in the absence of prototypes, all actual parameters are also promoted to double. In addition, the translator is really spotty about casting the actual parameters to type "float" at the point of call. It sometimes does the cast, and then again, often it does not. The reason this is an issue is for C++ *compiler* writers (those that generate code without going through a C compiler). What does the language spec say about this type-rewriting? Should it happen? It is unspecified, or does the language want to commit one way or another (say, do what ANSI C does)? If C++ is supposed to behave like C in this regard, where does that leave the translator? ----- Shankar Unni E-Mail: Hewlett-Packard California Language Lab. Internet: shankar@hpda.hp.com Phone : (408) 447-5797 UUCP: ...!hplabs!hpda!shankar