This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/71484] Class with implicit public constructor triggers `-Wctor-dtor-privacy`


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;
  ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]