c/6968: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
tmorelan@uoguelph.ca
tmorelan@uoguelph.ca
Fri Jun 7 18:16:00 GMT 2002
>Number: 6968
>Category: c
>Synopsis: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Fri Jun 07 18:16:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Terry Moreland
>Release: 2.95, 2.96, 3.1
>Organization:
>Environment:
Debian Linux (Potato)
Redhat Linux 7.2 (base install) glibc 2.2.2-10
Redhat Linux 7.3 (base install) glibc 2.2.5
>Description:
a function declared as taking no arguments accepts infinite arguments without complaint under -Wall -ansi -pedantic or any other standard
eg;
void test( ) {
printf("shouldn't compile\n");
}
int main(void) {
test( 1, 2, 3, "Hello", "World", "this", "shouldn't", "compile" );
return(0);
}
above code compiles and runs without error
>How-To-Repeat:
sample code:
#include <stdio.h>
void test( ) {
printf("shouldn't compile\n" );
}
int main(void) {
test( 1, 2, 3, "Hello", "World" );
return(0);
}
>Fix:
change prototype of function that shouldn't accept arguments
to use void as argument
eg;
void test(void);
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list