This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29545] New: error when mixing virtual and non virtual increment operators
- From: "raphael dot ribas at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Oct 2006 05:34:06 -0000
- Subject: [Bug c++/29545] New: error when mixing virtual and non virtual increment operators
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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