🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6172

Re: Possible gcc bugs?

#6172
From: Philippe.PEREZ
Date: Thu, 21 Nov 1996 00:00
47 lines
1659 bytes
Bhyrava Prasad wrote:
> 
> Hi ,
>    I am using gcc to cross complile for 68k on a Sun.
> gcc --version says it is 2.7-96q1.
>     Due to some error in cut and paste , I had a piece of code
> similar to
>     void foo()
>     {
>       void foo()
>       {
>           int i;
> 
>           some_function(i);
>           printf("hello world\n");
>        }
>      }
> 
>    And gcc compiled it just fine. Is this a bug? If not , what
> is happening?

No, it's not a bug. Your code is correct so why do you want gcc to
complain ?
Teh second declaration of foo hides the former one and becomes a local
function of the former function foo. There is nothing to say about that.
It's up to you to keep in mind when you call "foo()" what is the
function wich is known at the line you make the call.
It's the same thing when you make :

int i;

void foo()
{
	int i;
	i=1;
}

main
{
	i=1
}

the second "i" hides the first one and becomes local to the function
foo.

Philippe.
Technical Details
Message-ID: <329484E2.4487EB71@vx.cit.alcatel.fr>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3293AA98.6201DD56@cisco.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,24b2793880e68d18
X-Google-Attributes: gid113d02,public
From: "Philippe.PEREZ" <perez1%TCVR60@vx.cit.alcatel.fr>
Subject: Re: Possible gcc bugs?
Date: 1996/11/21
Message-ID: <329484E2.4487EB71@vx.cit.alcatel.fr>
X-Deja-AN: 197885866
sender: bug-gcc-request@prep.ai.mit.edu
references: <3293AA98.6201DD56@cisco.com>
content-type: text/plain; charset=us-ascii
organization: Alcatel/Bell
x-gateway: relay6.UU.NET from bug-gcc to gnu.gcc.bug; Thu, 21 Nov 1996 13:24:23 EST
mime-version: 1.0
newsgroups: gnu.gcc.bug
x-mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3_U1 sun4c)