This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/71484] Class with implicit public constructor triggers `-Wctor-dtor-privacy`
- From: "jlegg at feralinteractive dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 04 May 2018 11:08:53 +0000
- Subject: [Bug c++/71484] Class with implicit public constructor triggers `-Wctor-dtor-privacy`
- Auto-submitted: auto-generated
- References: <bug-71484-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71484
James Legg <jlegg at feralinteractive dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jlegg at feralinteractive dot com
--- Comment #1 from James Legg <jlegg at feralinteractive dot com> ---
In GCC 8.1, it can also be triggered without private methods, by explicitly
deleting the default copy constructor. For example:
struct S
{
S(const S &) = delete;
S & operator =(const S &) = delete;
int x;
};
Struct S has an implicit public constructor, despite which GCC 8.1 complains:
<source>:1:8: error: 'struct S' only defines private constructors and has no
friends [-Werror=ctor-dtor-privacy]
struct S
^
<source>:3:2: note: 'S::S(const S&)' is public, but requires an existing
'struct S' object
S(const S &) = delete;
^