Visual C++ 6.0 Namespace bug

Back to programming

namespace n1
{
    long c;
}

namespace n2
{
    using namespace n1;
    long d = c;
}

namespace n2
{
    using namespace n1; 
    long e = c;
}

namespace n2
{
    using namespace n1; 
    long f = c;
}

namespace n2
{
    using namespace n1; 
    long g = c;
}

namespace n2
{
    using namespace n1; 
    long h = c;
}

// In the third namespace extension
// this stops compiling due to errors. It says:
// error C2065: 'c': undeclared identifier
// although there is the "using namespace n1"

// Oddness 1: The error is "corrected" by
// explicitly substituting "n1::c" instead of just "c"

// Oddness 2: If the error was not "corrected", then
// the following identical namespace extensions
// result in errors that say:
// error C2872: 'c': ambiguous symbol

// Oddness 3: If the error was "corrected", then
// the program compiles without errors and
// the "n1::c" is only required in the _third_
// namespace extension.

int main()
{
    return 0;
}