[Bug c++/97443] New: gcc rejects an abstract class that could be used as a function return type due to the new rules
tangyixuan at mail dot dlut.edu.cn
gcc-bugzilla@gcc.gnu.org
Thu Oct 15 11:19:42 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97443
Bug ID: 97443
Summary: gcc rejects an abstract class that could be used as a
function return type due to the new rules
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tangyixuan at mail dot dlut.edu.cn
Target Milestone: ---
Hi, the abstract class could be used as a function return type, as well as the
parameter type and the type of an explicit conversion. Please see:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0929r2.html
gcc rejects the following valid program:
$ cat s.cpp
template<typename T>
struct S{};
struct A
{
virtual void func() = 0;
};
int main()
{
S<A(int)> s;
}
$ g++ -c s.cpp
s.cpp: In function ‘int main()’:
s.cpp:11:5: error: invalid abstract return type ‘A’
23 | S<A(int)> s;
| ^
s.cpp:4:8: note: because the following virtual functions are pure within ‘A’:
16 | struct A
| ^
s.cpp:6:16: note: ‘virtual void A::f()’
18 | virtual void f() = 0;
|
More information about the Gcc-bugs
mailing list