From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D5203388C009; Thu, 6 May 2021 09:38:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5203388C009 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99692] Lookup for operator<< skips global scope Date: Thu, 06 May 2021 09:38:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed see_also bug_status cf_reconfirmed_on Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 May 2021 09:38:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99692 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=3D51577 Status|UNCONFIRMED |NEW Last reconfirmed| |2021-05-06 --- Comment #10 from Jonathan Wakely --- Reduced: namespace std { struct ostream { }; template T&& declval(); template using void_t =3D void; struct false_type { static constexpr bool value =3D false; }; struct true_type { static constexpr bool value =3D true; }; template struct enable_if { }; template struct enable_if { using type =3D T; }; void __is_convertible_to_basic_ostream_test(ostream*); template struct __is_convertible_to_basic_ostream : false_type { }; template struct __is_convertible_to_basic_ostream<_Tp, decltype(__is_convertible_to_basic_ostream_test(declval<_Tp*>()))> : true_type { using __ostream_type =3D ostream&; }; template struct __is_convertible_to_basic_ostream<_Tp&> : false_type { using __ostream_type =3D void; }; template struct __is_insertable : false_type {}; template struct __is_insertable<_Ostream, _Tp, void_t() << declval())>> : true_type {}; template using __rvalue_ostream_type =3D typename __is_convertible_to_basic_ostream< _Ostream>::__ostream_type; template inline typename enable_if<__is_convertible_to_basic_ostream<_Ostream>::value && __is_insertable<__rvalue_ostream_type<_Ostream>, const _Tp&>::value, __rvalue_ostream_type<_Ostream>>::type operator<<(_Ostream&& __os, const _Tp&) { return __os; } } struct CustomStream : std::ostream {}; namespace N { class A{}; } std::ostream& operator<<(std::ostream& s, const N::A&)=20 { return s; } CustomStream& operator<<(CustomStream&& s, const N::A&)=20=20 { return s; } int main()=20 { CustomStream() << N::A{}; } Clang accepts this, GCC doesn't.=