Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!noao!arizona!naucse!jdc From: jdc@naucse.UUCP (John Campbell) Newsgroups: comp.lang.c Subject: VMS 'C' prototypes Message-ID: <434@naucse.UUCP> Date: Tue, 25-Aug-87 16:10:24 EDT Article-I.D.: naucse.434 Posted: Tue Aug 25 16:10:24 1987 Date-Received: Thu, 27-Aug-87 01:44:19 EDT Organization: Northern Arizona University, Flagstaff, Arizona Lines: 75 Keywords: Prototypes, VMS 'C' I'm not sure any comp.lang.c netters really care about the compiler I have been using (VMS latest release), but it seems to me the following implementation of prototypes is pretty screwy... From the VMS Guide to VAX C manual (VMS 'C' version 2.3-024): If the data type of an argument in a function call does not match the prototype, VAX C attempts to perform conversions. If the mismatched argument is assignment compatible with the prototype parameter, VAX C converts the argument to the data type specified in the prototype, according to the parameter and argument conversion rules (...). If the mismatched argument is not assignment compatible with the prototype parameter, the action generates the appropriate error message and the results are undefined. Here is a listing (with /MACHINE interspersed) of a program that compiles without any complaints: 1 2 void screwy (int aa, char **bb); 3 main() 4 { main: .entry main,^m subl2 #4,sp jsb C$MAIN 5 1 int a; 6 1 float b; 7 1 8 1 screwy (a, b); cvtfl r2,-(sp) pushl r3 calls #2,FARM_IT 9 1 } movl #1,r0 ret 10 11 void screwy (a, b) 12 int a; screwy: .entry screwy,^m<> subl2 #4,sp 13 float b; 14 { 15 1 b = a; cvtld 4(ap),8(ap) 16 1 } ret Changing the definition of ``screwy'' to use the new style function definition with this compiler (eg void screwy (int a, float b) {}) will cause the compiler to give an error message about mismatched arguments (which is what I wanted all along). Questions: Should old and new style definitions yield different behaviors? Is this the expected way to implement prototypes? Are prototypes all that useful in such an implementation? Is it really correct to CVTFL in the guise of "assignment compatibility"? If *anyone* would care to defend or attack the documentation or actual behavior of this compiler's use of prototypes, I would love to read all about it. jdc -- ..arizona!naucse!jdc 602-523-6259 (DEC, the inventors of runoff, use TeX!)