Bug 80851 - All versions that support C++11 are confused by combination of inherited constructors with member initializer that captures this
Summary: All versions that support C++11 are confused by combination of inherited cons...
Status: RESOLVED DUPLICATE of bug 67054
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2017-05-22 06:04 UTC by Paul L
Modified: 2021-08-12 01:55 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-05-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul L 2017-05-22 06:04:37 UTC
Tested with:
    4.8.1 - 7.1

Test case:

struct BaseFooWrapper
{
    BaseFooWrapper(int qux)
    { }
};

struct Foo
{
    Foo(BaseFooWrapper & foo)
        : foo(foo)
    { }

    BaseFooWrapper & foo;
};

struct SomeFooWrapper : public BaseFooWrapper
{
    using BaseFooWrapper::BaseFooWrapper;


    Foo foo{*this};
};

int main()
{
    SomeFooWrapper wrapped_foo(1);
    return 0;
}



Error output:


#1 with x86-64 gcc 7.1
<source>: In function 'int main()':
<source>:29:33: error: use of deleted function 'SomeFooWrapper::SomeFooWrapper(int) [inherited from BaseFooWrapper]'
     SomeFooWrapper wrapped_foo(1);
                                 ^
<source>:20:27: note: 'SomeFooWrapper::SomeFooWrapper(int) [inherited from BaseFooWrapper]' is implicitly deleted because the default definition would be ill-formed:
     using BaseFooWrapper::BaseFooWrapper;
                           ^~~~~~~~~~~~~~
<source>:20:27: error: no matching function for call to 'Foo::Foo()'
<source>:11:5: note: candidate: Foo::Foo(BaseFooWrapper&)
     Foo(BaseFooWrapper & foo)
     ^~~
<source>:11:5: note:   candidate expects 1 argument, 0 provided
<source>:9:8: note: candidate: constexpr Foo::Foo(const Foo&)
 struct Foo
        ^~~
<source>:9:8: note:   candidate expects 1 argument, 0 provided
<source>:9:8: note: candidate: constexpr Foo::Foo(Foo&&)
<source>:9:8: note:   candidate expects 1 argument, 0 provided
Comment 1 Daniel Boles 2017-05-22 08:10:06 UTC
This is presumably a duplicate of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054

unless the OP has evidence that capturing *this is relevant to whether or not the problem occurs
Comment 2 Richard Biener 2017-05-24 10:54:28 UTC
Confirmed.  clang accepts this.
Comment 3 Andrew Pinski 2021-08-12 01:55:19 UTC
This is a dup of bug 67054 which is fixed in GCC 7.2.0.

*** This bug has been marked as a duplicate of bug 67054 ***