If I have two struct
s with the same name, but each of them is written into it's own .cpp file, should it really be undefined behavior?
///////////////////////////////
// test1.h
class Foo
{
public :
void bar();
};
///////////////////////////////
// test2.h
class Foo2
{
public:
void bar();
};
///////////////////////////////
// test1.cpp
#include "test1.h"
struct Test
{
Test() :a(0){}
int a;
};
void Foo::bar()
{
Test t;
}
///////////////////////////////
// test2.cpp
#include "test2.h"
struct Test
{
Test() :a(0), b(0){}
int a, b;
};
void Foo2::bar()
{
Test t;
}
///////////////////////////////
// main.cpp
#include "test1.h"
#include "test2.h"
int main()
{
Foo2 f;
f.bar();
}
I have reported it to Microsoft as a bug here, but they responded, that this is undefined. Is it really? It look weird to me.