[Bug c++/71484] Class with implicit public constructor triggers `-Wctor-dtor-privacy`
jlegg at feralinteractive dot com
gcc-bugzilla@gcc.gnu.org
Fri May 4 11:08:00 GMT 2018
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;
^
More information about the Gcc-bugs
mailing list