public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "tilps at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/58119] New: Invalid ambiguous default type conversion with only a single invalid conversion listed. Date: Sat, 10 Aug 2013 12:42:00 -0000 [thread overview] Message-ID: <bug-58119-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58119 Bug ID: 58119 Summary: Invalid ambiguous default type conversion with only a single invalid conversion listed. Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tilps at hotmail dot com 'Minimal' test case: template <class type> class Silly { public: Silly(type *value) { data_ = value; } operator type*() const { return data_; } template <class other> operator Silly<other>() const { return Silly<other>(data_); } private: type *data_; }; int main() { Silly<int> a(nullptr); delete a; } Fails giving: test.cc:20:10: error: ambiguous default type conversion from 'Silly<int>' delete a; ^ test.cc:20:10: error: candidate conversions include 'template<class other> Silly<type>::operator Silly<other>() const [with other = other; type = int]' test.cc:20:10: error: type 'class Silly<int>' argument given to 'delete', expected pointer I believe that this code should be considered valid, the only valid type conversion is via the operator type *() which then converts to void* for the delete operator. I don't see any way that Silly<anything> could be considered convertible, except via operator type *() - and as far as I was aware, only a single implicit cast operator is allowed to be considered in a type conversion chain. Interestingly, the valid type conversion is not mentioned as a candidate, and the candidate mentioned does not specify which template parameter type it would use for the 'other' template parameter. Ultimately this is a bit of a strange example - I was trying to resurrect some legacy code with a particularly dumb (but heavily used) 'smart pointer' type. But this code did work, at least as recently as 4.6 - and probably back before 3.2.
next reply other threads:[~2013-08-10 12:42 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-08-10 12:42 tilps at hotmail dot com [this message] 2013-08-10 17:39 ` [Bug c++/58119] [4.7/4.8/4.9 Regression] " paolo.carlini at oracle dot com 2013-08-16 13:49 ` jakub at gcc dot gnu.org 2013-08-18 5:20 ` jason at gcc dot gnu.org 2013-08-20 13:00 ` 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-58119-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).