public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56943] New: Incorrect two-phase name lookup for operators
@ 2013-04-12 23:35 zeratul976 at hotmail dot com
  2013-04-13  0:33 ` [Bug c++/56943] " paolo.carlini at oracle dot com
  2013-04-13  0:45 ` zeratul976 at hotmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: zeratul976 at hotmail dot com @ 2013-04-12 23:35 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56943
           Summary: Incorrect two-phase name lookup for operators
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zeratul976@hotmail.com


When the following code is run:


#include <iostream>

namespace N
{
    struct A
    {
        int operator+(const void*) 
        { 
            return 42; 
        }
    };
}

namespace M
{
    struct B
    {
    };
}


template <typename T, typename U>
int add(T t, U u)
{
    return t + u;
}

int operator+(N::A, M::B*) 
{ 
    return 5; 
}

int main(int argc, char** argv)
{
    N::A a;
    M::B b;
    std::cout << add(a, &b) << "\n";
}


the output is "5". I believe the correct output wouldbe "42", because when
looking up operator+ in the expression "t + u", the operator+(N::A, M::B*)
overload is found neither by unqualified lookup at the point of definition
(since it is not declared yet at the point of definition), nor by
argument-dependent lookup at the point of instantiation (since it is not in the
namespace of either of its arguments).

Clang outputs "42" for this example, as expected.


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

* [Bug c++/56943] Incorrect two-phase name lookup for operators
  2013-04-12 23:35 [Bug c++/56943] New: Incorrect two-phase name lookup for operators zeratul976 at hotmail dot com
@ 2013-04-13  0:33 ` paolo.carlini at oracle dot com
  2013-04-13  0:45 ` zeratul976 at hotmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-13  0:33 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-04-13 00:33:04 UTC ---
Please double check this isn't a Dup of PR51577


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

* [Bug c++/56943] Incorrect two-phase name lookup for operators
  2013-04-12 23:35 [Bug c++/56943] New: Incorrect two-phase name lookup for operators zeratul976 at hotmail dot com
  2013-04-13  0:33 ` [Bug c++/56943] " paolo.carlini at oracle dot com
@ 2013-04-13  0:45 ` zeratul976 at hotmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: zeratul976 at hotmail dot com @ 2013-04-13  0:45 UTC (permalink / raw)
  To: gcc-bugs


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

Nathan Ridge <zeratul976 at hotmail dot com> changed:

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

--- Comment #2 from Nathan Ridge <zeratul976 at hotmail dot com> 2013-04-13 00:44:58 UTC ---
(In reply to comment #1)
> Please double check this isn't a Dup of PR51577

Looks that way. Closing.

*** This bug has been marked as a duplicate of bug 51577 ***


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

end of thread, other threads:[~2013-04-13  0:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-12 23:35 [Bug c++/56943] New: Incorrect two-phase name lookup for operators zeratul976 at hotmail dot com
2013-04-13  0:33 ` [Bug c++/56943] " paolo.carlini at oracle dot com
2013-04-13  0:45 ` zeratul976 at hotmail dot com

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