Bug 6326

Summary: gcc compile illegal code
Product: gcc Reporter: act.kronoz
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, gdr, gdr, jsm28
Priority: P3 Keywords: accepts-invalid
Version: 3.0.4   
Target Milestone: ---   
Host: i586-pc-linux-gnu Target: i586-pc-linux-gnu
Build: i586-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed:

Description act.kronoz 2002-04-16 08:26:01 UTC
Quoting from ISO C99:

6.7.5.3 Function declarators (including prototypes)
[...]
14 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.

I think that

int foo() {
	return 0;
}

should be equal to

int foo(void) {
	return 0;
}

gcc  do  not  complain  when  I  pass one  or  more  paramters  to  this
function. The code (see below) was compiled with:

gcc -Wall -std=c99 -op p.c

Release:
3.0.4

Environment:
System: Linux dreamland 2.4.18-xfs #2 Mon Mar 4 17:42:57 CET 2002 i586 unknown
Architecture: i586

	
host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr --with-slibdir=/lib --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-cpu=k6 --enable-threads : (reconfigured)

How-To-Repeat:
int foo() {
	return 0;
}

int main(void) {
	foo("bar");
	foo(1, 2, 3);
	foo(3.14);
}
Comment 1 Andrew Pinski 2002-07-12 23:02:27 UTC
From: Andrew Pinski <pinskia@physics.uc.edu>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, act.kronoz@activenetwork.it,
   gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c/6326: gcc compile illegal code
Date: Fri, 12 Jul 2002 23:02:27 -0400

 Even reading the standard from your bug report:
 `The empty list in a function=A0 declarator that is not part of
 a definition=A0 of that function=A0 specifies that no information=A0=20
 about the
 number or types of the parameters is supplied.'
 It looks like:
 int foo() {
 =A0 =A0 =A0 =A0 return 0;
 }
 
 should and is currently equal to, like K&R C,
 int foo(...) {
 =A0 =A0 =A0 =A0 return 0;
 }
 
 Therefore this bug report should be closed.
 
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audit-
 trail&database=3Dgcc&pr=3D6326
 
Comment 2 Neil Booth 2002-07-13 02:17:57 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.  An empty parameter list in a declaration indicates an unknown parameter list.
Comment 3 Gabriel Dos Reis 2002-09-10 16:33:59 UTC
State-Changed-From-To: closed->open
State-Changed-Why: Closed by mistake.
    Andrew Pinski's analysis is not applicable since the part he
    is reading concerns function declaration that is not a definition
    and we're precisely in a case where that is irrelevant.
    
    Furthermore, Neil's analysis alos isn't applicable.
Comment 4 Joseph S. Myers 2002-09-13 01:20:38 UTC
From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: <gdr@gcc.gnu.org>,  <act.kronoz@activenetwork.it>, 
     <gcc-bugs@gcc.gnu.org>,  <ptrebuc@sophia.inria.fr>, 
     <gcc-gnats@gcc.gnu.org>
Cc:  
Subject: Re: c/6326: gcc compile illegal code
Date: Fri, 13 Sep 2002 01:20:38 +0100 (BST)

 On 10 Sep 2002 gdr@gcc.gnu.org wrote:
 
 > Synopsis: gcc compile illegal code
 > 
 > State-Changed-From-To: closed->open
 > State-Changed-By: gdr
 > State-Changed-When: Tue Sep 10 16:33:59 2002
 > State-Changed-Why:
 >     Closed by mistake.
 >     Andrew Pinski's analysis is not applicable since the part he
 >     is reading concerns function declaration that is not a definition
 >     and we're precisely in a case where that is irrelevant.
 >     
 >     Furthermore, Neil's analysis alos isn't applicable.
 
 The PR is incorrect and based on a misunderstanding of C.  I gave my
 analysis in <http://gcc.gnu.org/ml/gcc-patches/2002-05/msg00046.html>.
 
 -- 
 Joseph S. Myers
 jsm28@cam.ac.uk
 

Comment 5 Gabriel Dos Reis 2002-09-13 03:56:54 UTC
State-Changed-From-To: open->closed
State-Changed-Why: See the audi trail. Especially, the reference given by Joseph.
Comment 6 Gabriel Dos Reis 2002-09-13 12:50:12 UTC
From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: "Joseph S. Myers" <jsm28@cam.ac.uk>
Cc: <act.kronoz@activenetwork.it>, <gcc-bugs@gcc.gnu.org>,
   <ptrebuc@sophia.inria.fr>, <gcc-gnats@gcc.gnu.org>
Subject: Re: c/6326: gcc compile illegal code
Date: 13 Sep 2002 12:50:12 +0200

 "Joseph S. Myers" <jsm28@cam.ac.uk> writes:
 
 | The PR is incorrect and based on a misunderstanding of C.  I gave my
 | analysis in <http://gcc.gnu.org/ml/gcc-patches/2002-05/msg00046.html>.
 
 Thanks.  I'll re-close the PR and add the reference you gave in the
 audit trail.
 
 -- Gaby