http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46449

           Summary: Class in a CPP override a class from another CPP
           Product: gcc
           Version: 4.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: charles.gorand....@gmail.com


Created attachment 22380
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22380
Full source and Makefile to reproduce the bug

Hi,

(Attachment contains full source to reproduce the issue)

I have a class declared in file1.cpp called SameClassName.
In file2.cpp there is also a class called SameClassName.

file1.h/file1.cpp contains definition of class File1 with the function bar()
This function instanciate SameClassName and called the function foo() from
SameClassName object.

file2.h/file2.cpp contains definition of class File2 with the function bar()
This function instanciate SameClassName and called the function foo()from
SameClassName object.


SameClassName from file1.cpp cannot be accessed by anybody. Same for the one of
file2.cpp.

If you look at source code, the expected result should be :

bar() from file1
-> new SameClassName from file1
-> foo() from file1
bar() from file2
-> new SameClassName from file2
-> foo() from file2

But with 2 gcc I get this : 

bar() from file1
-> new SameClassName from file1
-> foo() from file1
bar() from file2
-> new SameClassName from file1
-> foo() from file1

Reproduced with 2 different gcc :

$gcc --version
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)



$gcc --version
gcc (Debian 4.4.4-8) 4.4.5 20100728 (prerelease)


If in file2.cpp you rename foo() by foo2() and bar() called now foo2() :

bar() from file1
-> new SameClassName from file1
-> foo() from file1
bar() from file2
-> new SameClassName from file1
-> foo() from file2

Reply via email to