[Bug c++/37804] friend declaration leaks into global scope at template instantiation

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Oct 11 13:08:00 GMT 2008



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-10-11 13:07 -------
Confirmed.  The friend declaration seems to inject Internal_B into the global
namespace at the point of instantiating the template A.

Reduced testcase:

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

A<int> a; // here we inject a declaration of B into the global namespace

B some_function();  // B should not be declared here


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |accepts-invalid
   Last reconfirmed|0000-00-00 00:00:00         |2008-10-11 13:07:05
               date|                            |
            Summary|Nested type leaks to global |friend declaration leaks
                   |scope                       |into global scope at
                   |                            |template instantiation


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



More information about the Gcc-bugs mailing list