Visual C++ 6 compiler bugs

Back to Blog

Here are some of the bugs I have found in the Visual C++ 6 compiler.

getline

// Give an input of:
// one<enter>two<enter>three<enter>
//
// And the output is:
//
// > one
// two
// You gave: one
// > three
// You gave: two

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string text;

    cout << "> ";
    getline(cin, text);
    cout << "You gave: " << text << endl;

    cout << "> ";
    getline(cin, text);
    cout << "You gave: " << text << endl;

    return EXIT_SUCCESS;
}

Namespace

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;
}