an error occur when mixing non virtual post increment operator
with virtual pre increment operator
$ cat test.cpp
struct A {
const A& operator ++ (int) { return *this; }
virtual const A& operator++() = 0;
};
struct B : public A {
virtual const A& operator++() { return *this; }
};
int main(void) {
B teste;
teste++;
return 0;
}
$ g++-4.1 test.cpp
test.cpp: In function 'int main()':
test.cpp:12: error: no 'operator++(int)' declared for postfix '++', trying
prefix operator instead
$
and if I remove pre increment operator it compiles ok
$ cat test.cpp
struct A {
const A& operator ++ (int) { return *this; }
//virtual const A& operator++() = 0;
};
struct B : public A {
//virtual const A& operator++() { return *this; }
};
int main(void) {
B teste;
teste++;
return 0;
}
$ g++-4.1 test.cpp
$
--
Summary: error when mixing virtual and non virtual increment
operators
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: raphael dot ribas at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29545