From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24759 invoked by alias); 8 Jun 2002 06:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 24745 invoked by uid 71); 8 Jun 2002 06:56:01 -0000 Date: Fri, 07 Jun 2002 23:56:00 -0000 Message-ID: <20020608065601.24744.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Terry Moreland Subject: Re: c/6968: functions that shouldn't accept arguments accept infinite arguments (eg; test() ) Reply-To: Terry Moreland X-SW-Source: 2002-06/txt/msg00181.txt.bz2 List-Id: The following reply was made to PR c/6968; it has been noted by GNATS. From: Terry Moreland To: zack@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 --------------------------------------------------------