Bug 17644 - unexpected symbol redefinition error
Summary: unexpected symbol redefinition error
Status: RESOLVED DUPLICATE of bug 17353
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-23 22:23 UTC by Boris Kolpackov
Modified: 2005-07-31 05:40 UTC (History)
2 users (show)

See Also:
Host: i686-linux
Target: i686-linux
Build: i686-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Kolpackov 2004-09-23 22:23:23 UTC
$ cat >text.cxx
struct foo
{
};

struct bar
{
  foo
  foo ();
};

$ g++ --version
g++ (GCC) 3.3.4 (Debian 1:3.3.4-12)

$ g++ -c test.cxx
test.cxx:8: error: declaration of `foo bar::foo()'
test.cxx:2: error: changes meaning of `foo' from `struct foo'

$ g++-3.4 --version
g++-3.4 (GCC) 3.4.2 (Debian 3.4.2-2)

$ g++ -c test.cxx
test.cxx:8: error: declaration of `foo bar::foo()'
test.cxx:2: error: changes meaning of `foo' from `struct foo'

This code compiles fine with both intel c++ 8.1 and current comeau online.
Comment 1 Andrew Pinski 2004-09-23 22:50:47 UTC
No GCC is correct, foo cannot be redefined in the same class where you use it differently.
Comment 2 Boris Kolpackov 2004-09-24 18:52:19 UTC
And what about this:

class foo
{
};

struct bar
{
  ::foo
  foo ();
};

illegal too?

And this

struct bar
{
  struct foo
  {
  };

  foo
  foo ();
};

should definitely be illegal, right?

Comment 3 Andrew Pinski 2004-09-24 18:57:06 UTC
The first example is valid because ::foo is explicantly named but the second is invalid.  Basically in C++ 
you have to "reparse" the struct again after finishing the struct  and the standard says that if the type is 
different than before it is an error.
Comment 4 Boris Kolpackov 2004-09-24 19:06:50 UTC
> the second is invalid

however it is accepted by g++ 3.4.2

> Basically in C++ you have to "reparse" the struct again after finishing
> the struct  and the standard says that if the type is  different than 
> before it is an error.

You mean the type of symbol is different or the type is different? I always
thought that types and functions form separate symbol spaces. If what you are
saying is true then the following is illegal too, right?

struct foo
{
};

foo
foo ();

Comment 5 Andrew Pinski 2004-11-06 21:18:26 UTC
*** Bug 18320 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2005-07-31 05:40:14 UTC
Reopening to ...
Comment 7 Andrew Pinski 2005-07-31 05:40:41 UTC
Mark as a dup of bug 17353.

*** This bug has been marked as a duplicate of 17353 ***