public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "schaub.johannes at googlemail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/47080] explicit conversion function return conversions not restricted to qualifications Date: Tue, 28 Dec 2010 19:10:00 -0000 [thread overview] Message-ID: <bug-47080-4-sfwlsxMgWX@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-47080-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47080 --- Comment #1 from Johannes Schaub <schaub.johannes at googlemail dot com> 2010-12-28 19:10:25 UTC --- It should be noted that this can yield to ambiguities in combination with other conversion functions. Consider enum E { }; struct A { explicit operator int(); operator E(); }; bool operator!(E); int main() { !A(); // should work, but GCC rejects! } In this case, since GCC considers both "operator int" and "operator E" for the contextual conversion to bool, but neither is better than the other, it assigns the ambiguous conversion sequence for the builtin operator. For conversion to the E-taking one, it unambiguously uses "operator E". Since the ambiguous conversion sequence cannot be compared to any other conversion sequence, we have an ambiguity between the builtin operator and our own defined one. On a n3225-conforming implementation, both operator functions would use "operator E", and then it would be found that "operator!(E)" matches the return of the conversion function better than the built-in candidate, and would thus be selected. So it's really a "rejects-valid", as is basically any C++ issue of this sort anyway, since they can all be "exploited" by using SFINAE.
next prev parent reply other threads:[~2010-12-28 19:10 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-12-28 18:20 [Bug c++/47080] New: " schaub.johannes at googlemail dot com 2010-12-28 19:10 ` schaub.johannes at googlemail dot com [this message] 2011-06-20 4:11 ` [Bug c++/47080] [C++0x] " jason at gcc dot gnu.org 2011-06-20 14:43 ` jason at gcc dot gnu.org 2011-06-20 14:45 ` jason 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-47080-4-sfwlsxMgWX@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).