public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Is this a bug in gcc??
@ 2004-12-01 15:09 Martin York
  0 siblings, 0 replies; 7+ messages in thread
From: Martin York @ 2004-12-01 15:09 UTC (permalink / raw)
  To: gcc-help

 Name lastlong wrote:
> Hi,
> 
> I am expecting a error (redefinition of "a") from following piece of 
> code. But gcc (3.4.2) doesnot give any error.
> /////////////////
> int a;
> char b;
> int a;

Just to expand on what has already been said.
gcc/g++ behave as required by the standard. But to make sure we compare
apples to apples.

If you add the above to the file: test.c

gcc -c test.c   # Works Fine     (as expected)
g++ -c test.c   # Outputs errors (as expected)

Note that gcc is a C compiler (or should I say invokes the underlying C
Compiler by default) while g++ is a C++ compiler. NB If you name the
file test.cpp the content is C++ and the C++ compiler will be invoked no
matter how 'Gcc' is invoked (unless you explicitly override the
defaults).


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is this a bug in gcc??
  2004-12-01 11:55     ` Name lastlong
  2004-12-01 13:30       ` Eljay Love-Jensen
@ 2004-12-01 13:39       ` Nathan Sidwell
  1 sibling, 0 replies; 7+ messages in thread
From: Nathan Sidwell @ 2004-12-01 13:39 UTC (permalink / raw)
  To: Name lastlong; +Cc: gcc-help

Name lastlong wrote:
> Ok agreed!
> 
> But don't you think that C compiler (gcc) also output
> this error? 
if it did that, it would not be a C compiler.  What part
of 'gcc is a C compiler, where the above is not an error'
was unclear?

> My observation is gcc outputs error only if we try to
> initialise both instant of "a".
again, correct. doing that is an error in C

nathan
-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is this a bug in gcc??
  2004-12-01 13:30       ` Eljay Love-Jensen
@ 2004-12-01 13:35         ` Name lastlong
  0 siblings, 0 replies; 7+ messages in thread
From: Name lastlong @ 2004-12-01 13:35 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: gcc-help

Hi Eljay Love-Jensen,

Thanks a lot for ur reply. 
I understand it this time. :)

Regards,
Brew.

--- Eljay Love-Jensen <eljay@adobe.com> wrote:

> Hi Name lastlong,
> 
>  >But don't you think that C compiler (gcc) also
> output this error?
> 
> It's not an error in C, therefore a C compiler would
> be non-compliant to 
> the C standard if it produced an error.  (And it
> would break a lot of 
> correct code.)
> 
>  >My observation is gcc outputs error only if we try
> to initialise both 
> instant of "a".
> 
> In C, there is only one instance of "a".
> 
> Stroustrup talks about C/C++ incompatibility in his
> C++ Programming 
> Language (3rd and Special editions) on B.2.2.
> 
> HTH,
> --Eljay
> 
> 



		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is this a bug in gcc??
  2004-12-01 11:55     ` Name lastlong
@ 2004-12-01 13:30       ` Eljay Love-Jensen
  2004-12-01 13:35         ` Name lastlong
  2004-12-01 13:39       ` Nathan Sidwell
  1 sibling, 1 reply; 7+ messages in thread
From: Eljay Love-Jensen @ 2004-12-01 13:30 UTC (permalink / raw)
  To: Name lastlong; +Cc: gcc-help

Hi Name lastlong,

 >But don't you think that C compiler (gcc) also output this error?

It's not an error in C, therefore a C compiler would be non-compliant to 
the C standard if it produced an error.  (And it would break a lot of 
correct code.)

 >My observation is gcc outputs error only if we try to initialise both 
instant of "a".

In C, there is only one instance of "a".

Stroustrup talks about C/C++ incompatibility in his C++ Programming 
Language (3rd and Special editions) on B.2.2.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is this a bug in gcc??
  2004-12-01 11:03   ` Nathan Sidwell
@ 2004-12-01 11:55     ` Name lastlong
  2004-12-01 13:30       ` Eljay Love-Jensen
  2004-12-01 13:39       ` Nathan Sidwell
  0 siblings, 2 replies; 7+ messages in thread
From: Name lastlong @ 2004-12-01 11:55 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: gcc-help

Ok agreed!

But don't you think that C compiler (gcc) also output
this error? 
My observation is gcc outputs error only if we try to
initialise both instant of "a".

Regards.

--- Nathan Sidwell <nathan@codesourcery.com> wrote:

> Name lastlong wrote:
> > Hi,
> > 
> > I am expecting a error (redefinition of "a") from
> > following piece of code. But gcc (3.4.2) doesnot
> give
> > any error.
> > /////////////////
> > int a;
> > char b;
> > int a;
> > 
> > void foo(void)
> > {
> > return;
> > }
> > /////////////////
> > Instead, if we try initialising "a" at BOTH the
> > places, then it gives error.
> > VC++ gives this error anyway.
> 
> VC++ is a C++ compiler, where the above is an error
> gcc is a C compiler, where the above is not an error
> 
> nathan
> 
> -- 
> Nathan Sidwell    ::   http://www.codesourcery.com  
> ::     CodeSourcery LLC
> nathan@codesourcery.com    ::    
> http://www.planetfall.pwp.blueyonder.co.uk
> 
> 



	
		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Is this a bug in gcc??
  2004-12-01  9:39 ` Is this a bug in gcc?? Name lastlong
@ 2004-12-01 11:03   ` Nathan Sidwell
  2004-12-01 11:55     ` Name lastlong
  0 siblings, 1 reply; 7+ messages in thread
From: Nathan Sidwell @ 2004-12-01 11:03 UTC (permalink / raw)
  To: Name lastlong; +Cc: gcc-help

Name lastlong wrote:
> Hi,
> 
> I am expecting a error (redefinition of "a") from
> following piece of code. But gcc (3.4.2) doesnot give
> any error.
> /////////////////
> int a;
> char b;
> int a;
> 
> void foo(void)
> {
> return;
> }
> /////////////////
> Instead, if we try initialising "a" at BOTH the
> places, then it gives error.
> VC++ gives this error anyway.

VC++ is a C++ compiler, where the above is an error
gcc is a C compiler, where the above is not an error

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Is this a bug in gcc??
  2004-12-01  9:21 Assembly optimizations Nathan Sidwell
@ 2004-12-01  9:39 ` Name lastlong
  2004-12-01 11:03   ` Nathan Sidwell
  0 siblings, 1 reply; 7+ messages in thread
From: Name lastlong @ 2004-12-01  9:39 UTC (permalink / raw)
  To: gcc-help

Hi,

I am expecting a error (redefinition of "a") from
following piece of code. But gcc (3.4.2) doesnot give
any error.
/////////////////
int a;
char b;
int a;

void foo(void)
{
return;
}
/////////////////
Instead, if we try initialising "a" at BOTH the
places, then it gives error.
VC++ gives this error anyway.

Is it a bug???

Regards.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-12-01 15:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-01 15:09 Is this a bug in gcc?? Martin York
  -- strict thread matches above, loose matches on Subject: below --
2004-12-01  9:21 Assembly optimizations Nathan Sidwell
2004-12-01  9:39 ` Is this a bug in gcc?? Name lastlong
2004-12-01 11:03   ` Nathan Sidwell
2004-12-01 11:55     ` Name lastlong
2004-12-01 13:30       ` Eljay Love-Jensen
2004-12-01 13:35         ` Name lastlong
2004-12-01 13:39       ` Nathan Sidwell

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).