This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31300] New: undetected class name clash
- From: "thierry dot galas at med dot ge dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Mar 2007 17:48:23 -0000
- Subject: [Bug c++/31300] New: undetected class name clash
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
2 local classes with same name and sharing methods with same signature
mismatch in calling methods depending on link order
fangorn:thierry% g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /home/thierry/gcc-4.0.4/configure
Thread model: posix
gcc version 4.0.4
fangorn:thierry% g++ t1.cxx t2.cxx main.cxx
fangorn:thierry% ./a.out
X1
X1
fangorn:thierry% g++ t2.cxx t1.cxx main.cxx
fangorn:thierry% ./a.out
X2
X2
fangorn:thierry% more x.h
struct X {
virtual void print()=0;
};
X* getX1();
X* getX2();
fangorn:thierry% more t1.cxx
#include "x.h"
#include <iostream>
struct X1 : public X {
virtual void print () { std::cerr << " X1\n"; };
};
struct T : public X1 {
};
static X* x=new T();
X* getX1() { return x; };
fangorn:thierry% more t2.cxx
#include "x.h"
#include <iostream>
struct X2 : public X {
virtual void print () { std::cerr<< " X2\n"; };
};
struct T : public X2 {
};
static X* x=new T();
X* getX2() { return x; };
fangorn:thierry% more main.cxx
#include "x.h"
int main(int argc, char** argv) {
X* x1=getX1();
X* x2=getX2();
x1->print();
x2->print();
}
--
Summary: undetected class name clash
Product: gcc
Version: 4.0.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: thierry dot galas at med dot ge dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31300