public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "andrea_iob at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97584] New: ADL inconsistency when calling the stream operator with x << y or with operator<<(x,y) Date: Mon, 26 Oct 2020 20:57:55 +0000 [thread overview] Message-ID: <bug-97584-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97584 Bug ID: 97584 Summary: ADL inconsistency when calling the stream operator with x << y or with operator<<(x,y) Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: andrea_iob at hotmail dot com Target Milestone: --- Created attachment 49442 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49442&action=edit Example code that shows the problem. This started as a possible bug in clang, but it seems it may be a bug in gcc instead. In the attached example I'm declaring a template stream (<<) operator, then I'm declaring a non-template operator in a different namespace. Depending on how I call the stream operator, x << y vs operator<<(x, y), I get two different behaviours: in the first case the non-template operator is called whereas in the latter the template operator is called. # g++ -o test test.cpp # ./test Using x << y syntax: > NON-TEMPLATE STREAM OPERATOR FOR CLASS data::Data Using operator<<(x, y) syntax: > TEMPLATE STREAM OPERATOR (I've tried gcc 10.2.1, gcc 7.5.0, and gcc 4.8.5.) Running the same example with clang I get a consistent behaviour: the template stream operator is selected. # clang++ -o test test.cpp # ./test Using x << y syntax: > TEMPLATE STREAM OPERATOR Using operator<<(x, y) syntax: > TEMPLATE STREAM OPERATOR This is the clang bugzilla entry: https://bugs.llvm.org/show_bug.cgi?id=47967 Let me know if further details are required. Thanks.
next reply other threads:[~2020-10-26 20:57 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-26 20:57 andrea_iob at hotmail dot com [this message] 2020-10-27 13:55 ` [Bug c++/97584] " redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-97584-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).