jsa@edg1.UUCP (J. Stephen Adamczyk) (02/09/91)
Is the following program legal? int f(int a, ...); int f(a) int a; { return 0; } The rules for function type compatibility in 3.5.4.3 say that "If one type has a parameter type list and the other type is specified by a function definition that contains a (possibly empty) identifier list, both shall agree in the number of parameters, and the type of each prototype parameter shall be compatible with the type that results from the application of the default argument promotions to the type of the corresponding identifier." Note that of the three cases discussed in the paragraph, only this one fails to mention an ellipsis compatibility requirement. An oversight? An intentional omission? Steve Adamczyk (jsa@edg.com or uunet!edg1!jsa; 201-744-2620)
gwyn@smoke.brl.mil (Doug Gwyn) (02/09/91)
In article <947@edg1.UUCP> jsa@edg1.UUCP (J. Stephen Adamczyk) writes: >int f(int a, ...); >int f(a) int a; { return 0; } Since they disagree in the use of ellipsis, 3.5.4.3 says they're incompatible.
henry@zoo.toronto.edu (Henry Spencer) (02/10/91)
In article <947@edg1.UUCP> jsa@edg1.UUCP (J. Stephen Adamczyk) writes: >Is the following program legal? > >int f(int a, ...); >int f(a) int a; { return 0; } I would say not; the number of parameters is supposed to match, and the declaration has one or more parameters while the definition has exactly one. >Note that of the three cases discussed in the paragraph, only >this one fails to mention an ellipsis compatibility requirement. My gut reaction is that the mention of it in the first is redundant, and in the second it is necessary to separate two different cases of "number of parameters unknown" (no information vs. varargs). I'll agree that the wording could have been tighter. -- "Maybe we should tell the truth?" | Henry Spencer at U of Toronto Zoology "Surely we aren't that desperate yet." | henry@zoo.toronto.edu utzoo!henry