public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97279] New: GCC ignores the operation definition of the template
@ 2020-10-03 12:13 tangyixuan at mail dot dlut.edu.cn
  2020-10-05 16:47 ` [Bug c++/97279] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: tangyixuan at mail dot dlut.edu.cn @ 2020-10-03 12:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97279

            Bug ID: 97279
           Summary: GCC ignores the operation definition of the template
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tangyixuan at mail dot dlut.edu.cn
  Target Milestone: ---

Hi, gcc selects the overloaded definition operation+() although it is not
declared before.

$ cat s.cpp

#include <iostream>
struct S {
    template <typename T>
    void operator+(T) { std::cout << "1" <<"\n"; }
};
namespace N {
    template <typename T>
    void func(const T value1) { S s; s +(value1); }
}

struct S1 {};
namespace N {
    void operator+(S&, S1) { std::cout << "2" <<"\n"; }
}

int main(int, char**)
{
    S1 s1;
    N::func(s1);
}

$ g++ s.cpp
$ ./a.out
2

$ clang++ s.cpp
$ ./a.out
1

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

end of thread, other threads:[~2021-12-08 16:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03 12:13 [Bug c++/97279] New: GCC ignores the operation definition of the template tangyixuan at mail dot dlut.edu.cn
2020-10-05 16:47 ` [Bug c++/97279] " mpolacek at gcc dot gnu.org
2020-10-05 23:08 ` harald at gigawatt dot nl
2020-10-07 16:15 ` mpolacek at gcc dot gnu.org
2021-08-04 17:42 ` pinskia at gcc dot gnu.org
2021-12-08 14:32 ` marxin at gcc dot gnu.org
2021-12-08 16:31 ` pinskia 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).