public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39770]  New: Function template can find a struct in same namespace/other namespace but not inside a function
@ 2009-04-14 19:14 mlybbert at users dot sourceforge dot net
  2009-04-14 19:24 ` [Bug c++/39770] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mlybbert at users dot sourceforge dot net @ 2009-04-14 19:14 UTC (permalink / raw)
  To: gcc-bugs

The following code does not compile ( error: no matching function for call to
`<unnamed>::A::print(main()::B&) ):

#include <iostream>

namespace {
        struct A {
                template<class C> void print(C c)
                {
                        c.print();
                }
        };

}

int main()
{
        A a;
        struct B {
                void print()
                {
                        std::cout << "whee!";
                }
        };
        B b;
        a.print(b);
}

However, defining B in the same namespace as A, in a different namespace, or
even in the global namespace compiles and works as expected.  I don't know the
standard well enough to say if this is correct behavior, but it seems like an
odd rule.


-- 
           Summary: Function template can find a struct in same
                    namespace/other namespace but not inside a function
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mlybbert at users dot sourceforge dot net


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/39770] Function template can find a struct in same namespace/other namespace but not inside a function
  2009-04-14 19:14 [Bug c++/39770] New: Function template can find a struct in same namespace/other namespace but not inside a function mlybbert at users dot sourceforge dot net
@ 2009-04-14 19:24 ` pinskia at gcc dot gnu dot org
  2009-04-14 19:26 ` paolo dot carlini at oracle dot com
  2009-04-14 21:57 ` mlybbert at users dot sourceforge dot net
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-04-14 19:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-04-14 19:24 -------
Local classes cannot be template arguments.


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/39770] Function template can find a struct in same namespace/other namespace but not inside a function
  2009-04-14 19:14 [Bug c++/39770] New: Function template can find a struct in same namespace/other namespace but not inside a function mlybbert at users dot sourceforge dot net
  2009-04-14 19:24 ` [Bug c++/39770] " pinskia at gcc dot gnu dot org
@ 2009-04-14 19:26 ` paolo dot carlini at oracle dot com
  2009-04-14 21:57 ` mlybbert at users dot sourceforge dot net
  2 siblings, 0 replies; 4+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-04-14 19:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2009-04-14 19:26 -------
Yes.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/39770] Function template can find a struct in same namespace/other namespace but not inside a function
  2009-04-14 19:14 [Bug c++/39770] New: Function template can find a struct in same namespace/other namespace but not inside a function mlybbert at users dot sourceforge dot net
  2009-04-14 19:24 ` [Bug c++/39770] " pinskia at gcc dot gnu dot org
  2009-04-14 19:26 ` paolo dot carlini at oracle dot com
@ 2009-04-14 21:57 ` mlybbert at users dot sourceforge dot net
  2 siblings, 0 replies; 4+ messages in thread
From: mlybbert at users dot sourceforge dot net @ 2009-04-14 21:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mlybbert at users dot sourceforge dot net  2009-04-14 21:56 -------
Thank you.


-- 


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-14 21:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14 19:14 [Bug c++/39770] New: Function template can find a struct in same namespace/other namespace but not inside a function mlybbert at users dot sourceforge dot net
2009-04-14 19:24 ` [Bug c++/39770] " pinskia at gcc dot gnu dot org
2009-04-14 19:26 ` paolo dot carlini at oracle dot com
2009-04-14 21:57 ` mlybbert at users dot sourceforge dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).