Bug 71774 - [4.9/5/6/7 regression] Bogus "is protected" error when list-initializing a base class with a defaulted protected constructor and a virtual function
Summary: [4.9/5/6/7 regression] Bogus "is protected" error when list-initializing a ba...
Status: RESOLVED DUPLICATE of bug 63151
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P2 normal
Target Milestone: 4.9.4
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2016-07-06 05:21 UTC by TC
Modified: 2016-07-22 22:16 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.7.0, 5.3.0, 6.1.0, 7.0
Last reconfirmed: 2016-07-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description TC 2016-07-06 05:21:03 UTC
Reduced from http://stackoverflow.com/q/38213809/2756719. Repro:

class Meow
{
  protected:
    Meow() =default;        
    virtual void f() {}
};

class Purr : public Meow
{
  public:
    Purr()
      : Meow{}
    {}  
};

prog.cc: In constructor 'Purr::Purr()':
prog.cc:12:14: error: 'constexpr Meow::Meow()' is protected within this context
       : Meow{}
              ^
prog.cc:4:5: note: declared protected here
     Meow() =default;
     ^~~~

Possibly related to PR63151, however this example reproduces in GCC 4.7.3 and 4.8.5 (on Wandbox), while that PR is known to work in 4.8.2.
Comment 1 Martin Sebor 2016-07-06 16:07:17 UTC
Confirmed with r175640 as the apparent cause of the regression:

r175640 | jason | 2011-06-29 10:09:03 -0400 (Wed, 29 Jun 2011) | 3 lines

	* init.c (build_value_init): Decide whether or not to zero-initialize
	based on user-providedness of default ctor, not any ctor.
	(build_value_init_noctor): Adjust assert.
Comment 2 Daniel Boles 2016-07-06 16:40:44 UTC
see also 66847, 66617, 55922
Comment 3 Jason Merrill 2016-07-22 22:16:02 UTC
Yep, same issue as 63151.

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