[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: bug report
From: Cristi Vlasceanu <CristiV () netzip ! com>
Date: 1999-12-22 19:31:41
[Download RAW message or body]
// This code demonstrates a bug in the following compilers:
//
// MSVC++ 6.0 (sp3)
// Code Warrior 5.0
// egcs 2.91.60 (system: Caldera Open Linux 2.1, command line: g++ main.cpp)
// Comeau 4.2.42 (online test drive)
#include <iostream>
using namespace std;
class A
{
public:
A() {}
/* explicit */ A(int) {}
virtual void Func() const = 0;
};
void Fubar(const A& a)
{
a.Func();
}
int main()
{
// error: cannot instantiate abstract class
// A a;
// error: cannot instantiate abstract class
// A a(42);
try
{
// *****************************************
// implicit conversion to abstract class A,
// should not compile but it does, when using:
// MSVC++ 6.0 (sp3)
// Code Warrior 5.0
// egcs 2.91.60
// Comeau 4.2.42
// The error is promptly detected by Borland
// C++ Builder 4.0
Fubar(42);
// error: cannot instantiate abstract class
// throw A();
// compiles fine under MSVC 6.0 SP3, but
// shouldn't
// throw A(0);
}
catch (A& a)
{
a.Func();
}
return 0;
}
Cristian Vlasceanu,
Software Engineer, Netzip Inc.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic