public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "seysayux at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/45383] New: [g++ >= 4.5 ] Implicit conversion to pointer does no longer automatically generate operator== and operator!=. Date: Mon, 23 Aug 2010 13:00:00 -0000 [thread overview] Message-ID: <bug-45383-19596@http.gcc.gnu.org/bugzilla/> (raw) Consider this code: -------------------- #include <iostream> struct null { null() {} template<class T> operator T*() const { return 0; } template<class C, class T> operator T C::*() const { return 0; } private: null(const null&); null& operator=(const null&); void operator&() const; }; static struct null null; int main() { int* ptr = null; std::cout << (ptr == null) << ", " << (ptr != null); return 0; } -------------------------------- This compiles and gives the expected output ("true, false") on the following platforms: http://codepad.org (GCC 4.1, Linux) Ubuntu 9.10, GCC 4.3 Ubuntu 10.04, GCC 4.4 Mac OS X 10.6, GCC 4.2 Mac OS X 10.6, GCC 4.4 Cygwin, GCC 4.3 Cygwin, GCC 4.4 Unknown Linux variant, Clang 2.8 (trunk 111679) (the "clang" bot on irc.freenode.net) However, I get following error on these platforms ------------- error: no match for 'operator==' in 'ptr == null' ------------- Cygwin, GCC 4.5 Ubuntu 10.04, GCC 4.5 Unknown Linux variant, GCC 4.6.0 20100507 (the "geordi" bot on irc.freenode.net) The people in the irc.freenode.net/##c++ channel confirm that this is indeed valid C++ code and therefore a bug in GCC. I do not have ready access to some of these systems (anymore), so I can not say with certainity what their host, target, or build triplets are. -- Summary: [g++ >= 4.5 ] Implicit conversion to pointer does no longer automatically generate operator== and operator!=. Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: seysayux at gmail dot com GCC build triplet: (many, read below) GCC host triplet: (many, read below) GCC target triplet: (many, read below) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45383
next reply other threads:[~2010-08-23 13:00 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-08-23 13:00 seysayux at gmail dot com [this message] 2010-08-23 13:17 ` [Bug c++/45383] [4.5/4.6 Regression] " redi at gcc dot gnu dot org 2010-08-23 16:35 ` hjl dot tools at gmail dot com 2010-08-23 20:07 ` rguenth at gcc dot gnu dot org 2010-08-30 16:01 ` rguenth at gcc dot gnu dot 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-45383-19596@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).