[Bug c++/56071] friend class template cannot access private constructor in exception-specification

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 21 22:59:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56071

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-01-21
            Summary|noexcept with template and  |friend class template
                   |private ctor fails          |cannot access private
                   |                            |constructor in
                   |                            |exception-specification
     Ever Confirmed|0                           |1
      Known to fail|                            |4.7.2, 4.8.0

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-21 22:59:35 UTC ---
Slightly reduced:

class B
{
  template <typename T> friend struct A;
  B() {}
};

template <typename T>
struct A
{
  A() noexcept(noexcept(B())) { }
};

struct C
{
  C()
  {
    static_assert( !noexcept(A<int>()), "" );
  }
};


The same access failure happens if the noexcept operator is replaced with
sizeof:

class B
{
  template <typename T> friend struct A;
  B() {}
};

template <typename T>
struct A
{
  A() noexcept(sizeof(B{})) { }
};

struct C
{
  C()
  {
    static_assert( sizeof(A<int>{}), "" );
  }
};



More information about the Gcc-bugs mailing list