public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51577] New: dependent name lookup finds operator in global namespace
@ 2011-12-16 12:13 redi at gcc dot gnu.org
  2012-01-21 23:31 ` [Bug c++/51577] " redi at gcc dot gnu.org
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-16 12:13 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51577
           Summary: dependent name lookup finds operator in global
                    namespace
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


template<typename T, typename U>
bool test( T v1, U v2 )
{
    // g(v1, v2);  // fails
    v1 == v2;
}

namespace A {
    struct X { };
}

namespace B {
    struct Y { };
}

void g(A::X, B::Y) { }

bool operator==(A::X, B::Y) { return true; }


int main()
{
  test( A::X(), B::Y() );
}

This should be rejected, but lookup using associated namespaces finds
operator== in the global namespace.  It should only look in namespace A.

If the call uses the function g() instead of an operator, name lookup fails as
expected.  If namespace A and the operator== are in an enclosing namespace it
also fails, the bug only seems to happen when operator== is in the global
namespace.


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

end of thread, other threads:[~2023-09-15 18:04 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-16 12:13 [Bug c++/51577] New: dependent name lookup finds operator in global namespace redi at gcc dot gnu.org
2012-01-21 23:31 ` [Bug c++/51577] " redi at gcc dot gnu.org
2013-04-13  0:45 ` zeratul976 at hotmail dot com
2013-04-13 11:17 ` redi at gcc dot gnu.org
2013-04-13 11:26 ` daniel.kruegler at googlemail dot com
2013-04-13 11:52 ` redi at gcc dot gnu.org
2013-04-13 11:55 ` daniel.kruegler at googlemail dot com
2013-04-13 12:11 ` paolo.carlini at oracle dot com
2014-05-12 23:45 ` richard-gccbugzilla at metafoo dot co.uk
2015-03-09 10:10 ` redi at gcc dot gnu.org
2015-03-09 10:11 ` redi at gcc dot gnu.org
2015-03-09 10:11 ` redi at gcc dot gnu.org
2020-03-18 17:20 ` redi at gcc dot gnu.org
2020-10-27 13:55 ` redi at gcc dot gnu.org
2020-10-27 13:56 ` redi at gcc dot gnu.org
2020-10-27 13:56 ` redi at gcc dot gnu.org
2020-10-27 13:57 ` redi at gcc dot gnu.org
2020-10-27 15:02 ` nathan at gcc dot gnu.org
2021-05-06 14:12 ` ppalka at gcc dot gnu.org
2021-05-06 18:10 ` jason at gcc dot gnu.org
2021-05-06 19:00 ` ppalka at gcc dot gnu.org
2021-05-11  2:39 ` cvs-commit at gcc dot gnu.org
2021-05-20 20:13 ` ppalka at gcc dot gnu.org
2021-12-16 18:41 ` cvs-commit at gcc dot gnu.org
2021-12-16 18:44 ` ppalka at gcc dot gnu.org
2023-09-15 18:04 ` ppalka at gcc dot gnu.org

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).