Bug 65615 - gcc says abstract class even though it isn't
Summary: gcc says abstract class even though it isn't
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.2
: P3 normal
Target Milestone: 7.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2015-03-27 23:32 UTC by gartenriese
Modified: 2021-07-31 21:30 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 6.0
Last reconfirmed: 2016-01-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gartenriese 2015-03-27 23:32:28 UTC
The following does not compile with gcc 4.9.2

class O {};

class D : public virtual O {
public:
    virtual float foo() const = 0;
};

class B : public D {
public:
    B(float, float) {}
};

class R : public B {
public:
    R() : B{1.f, 1.f} {}
    virtual float foo() const override { return 0.f; }
};

int main() {
    R r;
}

It says it cannot instantiate an object of abstract class B.
With Clang 3.6 it compiles.
See discussion here: http://stackoverflow.com/questions/29289857/base-class-with-pure-virtual-functions

If I use () instead of {} to create B, it compiles.
If B has only one parameter in the constructor instead of two, it compiles.
Comment 1 Andrew Pinski 2021-07-31 21:30:44 UTC
Fixed in GCC 7+.  I suspect by r7-3590 .