public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97584] New: ADL inconsistency when calling the stream operator with x << y or with operator<<(x,y)
@ 2020-10-26 20:57 andrea_iob at hotmail dot com
2020-10-27 13:55 ` [Bug c++/97584] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: andrea_iob at hotmail dot com @ 2020-10-26 20:57 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-27 13:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 20:57 [Bug c++/97584] New: ADL inconsistency when calling the stream operator with x << y or with operator<<(x,y) andrea_iob at hotmail dot com
2020-10-27 13:55 ` [Bug c++/97584] " redi 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).