public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/6968: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
@ 2002-06-07 22:56 zack
0 siblings, 0 replies; 5+ messages in thread
From: zack @ 2002-06-07 22:56 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, tmorelan
Synopsis: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
State-Changed-From-To: open->closed
State-Changed-By: zack
State-Changed-When: Fri Jun 7 22:56:53 2002
State-Changed-Why:
This is not a bug. The C standard specifies that a
function declared with an empty parameter list (such
as your void test ( ) ) accepts an indefinite number
of arguments, not zero arguments. You must write
void test ( void ) if you want to declare a function
accepting zero arguments.
(You may have C confused with C++. In C++ the rule
is as you expected.)
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6968
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: c/6968: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
@ 2002-06-08 12:46 Terry Moreland
0 siblings, 0 replies; 5+ messages in thread
From: Terry Moreland @ 2002-06-08 12:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/6968; it has been noted by GNATS.
From: Terry Moreland <tmorelan@q.cis.uoguelph.ca>
To: "Joseph S. Myers" <jsm28@cam.ac.uk>
Cc: zack@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>
Subject: Re: c/6968: functions that shouldn't accept arguments accept infinite
arguments (eg; test() )
Date: Sat, 8 Jun 2002 15:29:18 -0400 (EDT)
ok, I'll accept that, but still passing arguments to a function defined in this
way should still produce a warning since the arguments are inaccessible from
within the function and it just looks wrong
Terry
On Sat, 8 Jun 2002, Joseph S. Myers wrote:
> On Sat, 8 Jun 2002, Terry Moreland wrote:
>
> > mean that in c99 void test() is a function that takes no arguments since
> > enmpty identifier list is part of the function definition and as such the
> > void test() example should produce an error in c99, but doesn't in gcc 3.1 using
> > -std=c99
> >
> > please let me know if I am wrong, I have slept in a while and the iso c99 spec
> > can be very wordy at times
>
> It specifies, for the purposes of the definition, that it has no
> parameters. It does not, for the purposes of subsequent calls to the
> function, give it a type that includes a prototype, so the subsequent
> calls are not checked.
>
>
--
--------------------------------------------------------
Terry Moreland | Computer and Information Science
tmorelan@uoguelph.ca | University of Guelph
If you were plowing a field, which would you rather use?
Two strong oxen or 1024 chickens?
- Seymour Cray (1925-1996), father of supercomputing
--------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: c/6968: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
@ 2002-06-08 2:46 Joseph S. Myers
0 siblings, 0 replies; 5+ messages in thread
From: Joseph S. Myers @ 2002-06-08 2:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/6968; it has been noted by GNATS.
From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: Terry Moreland <tmorelan@q.cis.uoguelph.ca>
Cc: <zack@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>
Subject: Re: c/6968: functions that shouldn't accept arguments accept infinite
arguments (eg; test() )
Date: Sat, 8 Jun 2002 10:41:30 +0100 (BST)
On Sat, 8 Jun 2002, Terry Moreland wrote:
> mean that in c99 void test() is a function that takes no arguments since
> enmpty identifier list is part of the function definition and as such the
> void test() example should produce an error in c99, but doesn't in gcc 3.1 using
> -std=c99
>
> please let me know if I am wrong, I have slept in a while and the iso c99 spec
> can be very wordy at times
It specifies, for the purposes of the definition, that it has no
parameters. It does not, for the purposes of subsequent calls to the
function, give it a type that includes a prototype, so the subsequent
calls are not checked.
--
Joseph S. Myers
jsm28@cam.ac.uk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: c/6968: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
@ 2002-06-07 23:56 Terry Moreland
0 siblings, 0 replies; 5+ messages in thread
From: Terry Moreland @ 2002-06-07 23:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/6968; it has been noted by GNATS.
From: Terry Moreland <tmorelan@q.cis.uoguelph.ca>
To: zack@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>,
<nobody@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>
Cc:
Subject: Re: c/6968: functions that shouldn't accept arguments accept infinite
arguments (eg; test() )
Date: Sat, 8 Jun 2002 02:44:36 -0400 (EDT)
I might be reading this wrong but does not:
An identifier list declares only the identifiers of the parameters of the function. An empty
list in a function declarator that is part of a definition of that function specifies that the
function has no parameters. The empty list in a function declarator that is not part of a
definition of that function specifies that no information about the number or types of the
parameters is supplied.124)
( ISO 9899:1999 Section 6.7.5.3 Paragraph 14 )
mean that in c99 void test() is a function that takes no arguments since
enmpty identifier list is part of the function definition and as such the
void test() example should produce an error in c99, but doesn't in gcc 3.1 using
-std=c99
please let me know if I am wrong, I have slept in a while and the iso c99 spec
can be very wordy at times
the reference 124 leads to 6.11.6 which mentions:
The use of function declarators with empty parentheses (not prototype-format parameter
type declarators) is an obsolescent feature.
Terry
On 8 Jun 2002 zack@gcc.gnu.org wrote:
> Synopsis: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
>
> State-Changed-From-To: open->closed
> State-Changed-By: zack
> State-Changed-When: Fri Jun 7 22:56:53 2002
> State-Changed-Why:
> This is not a bug. The C standard specifies that a
> function declared with an empty parameter list (such
> as your void test ( ) ) accepts an indefinite number
> of arguments, not zero arguments. You must write
> void test ( void ) if you want to declare a function
> accepting zero arguments.
>
> (You may have C confused with C++. In C++ the rule
> is as you expected.)
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6968
>
--
--------------------------------------------------------
Terry Moreland | Computer and Information Science
tmorelan@uoguelph.ca | University of Guelph
If you were plowing a field, which would you rather use?
Two strong oxen or 1024 chickens?
- Seymour Cray (1925-1996), father of supercomputing
--------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* c/6968: functions that shouldn't accept arguments accept infinite arguments (eg; test() )
@ 2002-06-07 18:16 tmorelan
0 siblings, 0 replies; 5+ messages in thread
From: tmorelan @ 2002-06-07 18:16 UTC (permalink / raw)
To: gcc-gnats
>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:
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-06-08 19:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-07 22:56 c/6968: functions that shouldn't accept arguments accept infinite arguments (eg; test() ) zack
-- strict thread matches above, loose matches on Subject: below --
2002-06-08 12:46 Terry Moreland
2002-06-08 2:46 Joseph S. Myers
2002-06-07 23:56 Terry Moreland
2002-06-07 18:16 tmorelan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).