https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71484

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-08-15
     Ever confirmed|0                           |1
           Severity|minor                       |normal

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Here's a case where I think the warning is too noisy:

template<typename T>
class trait
{
  template<typename U>
    static U get();

public:
  using type = decltype(get<T>());
};

trait<int> i;

When compiled with -Wctor-dtor-privacy this warns:

tr.cc:2:7: warning: all member functions in class 'trait<T>' are private
[-Wctor-dtor-privacy]
    2 | class trait
      |       ^~~~~

The member function is supposed to be private. It's used by the
typedef-declaration, but only the typedef needs to be public.

The documentation for the warning says "Also warn if there are no non-private
methods, and there's at least one private member function that isn't a
constructor or destructor." I think the warning should be suppressed if those
private member functions are used by a public typedef.

Reply via email to