[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: egcs-1.1.2 create abstract class
From: Carlo Wood <carlo () runaway ! xs4all ! nl>
Date: 1999-10-01 1:49:53
[Download RAW message or body]
Hiya, I got this one from a news group
From: raoulgough@my-deja.com
Newsgroups: comp.lang.c++.moderated
Subject: Compiler automatically generates abstract object (crash)
Date: 29 Sep 1999 02:44:17 -0400
~/c++/tests>g++ abstract.cc
~/c++/tests>a.out
virtfn from object at 0xbffff4b4
pure virtual method called
Reason being that g++ happily constructed an abstract object,
with a pure virtual function. I am not 100% sure this is bug
but I thought I'd let you know.
--
Carlo Wood <carlo@runaway.xs4all.nl>
abstract.cc:
#include <iostream>
struct Abstract
{
Abstract (int) {}
virtual void virtfn (void) const = 0; // pure virtual
};
struct Concrete : public Abstract
{
Concrete (int i) : Abstract (i) {}
virtual void virtfn (void) const
{
cout
<< "virtfn from object at "
<< static_cast<const void *> (this)
<< endl;
}
};
void call_virtfn (const Abstract& a)
{
a.virtfn();
}
void main ()
{
call_virtfn (Concrete (1)); // Ok, of course
call_virtfn (2); // Creates Abstract(2)
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic