[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: [Bug c++/30340] New: pure virtual function called on const & declared with previous declaration wit
From: "mjtruog at fastmail dot ca" <gcc-bugzilla () gcc ! gnu ! org>
Date: 2006-12-31 21:35:51
Message-ID: bug-30340-13845 () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]
I have an example that illustrates the problem since it is rather hard to
describe in an easy to understand way. Notice how the alternative constructor
for C gives an unrelated compile time error (that may be a separate or related
problem). This could be understood and accepted behavior but it really does
seem quite strange... please tell me if this is the way things should work (C++
standard does not endorse this behavior, does it?).
class A;
class C
{
public:
C(int i, A const &test) : m_test(test) { i = 0;}
C(A const &test) : m_test(test) {}
void a() const;
private:
A const & m_test;
};
class A
{
public:
virtual ~A() {}
virtual void a() const = 0;
};
void C::a() const { m_test.a(); }
class B : public A
{
public:
void a() const { int i = 1; i *= 1; }
};
int main()
{
// using this constructor causes "error: request for member 'a' in 'c',
which is of non-class type 'C ()(B (*)())'"
//C c(B());
// this constructor allows the example to compile
C c(1, B());
c.a();
}
--
Summary: pure virtual function called on const & declared with
previous declaration without a definition, const &
assigned by temporary
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mjtruog at fastmail dot ca
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30340
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic