From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12293 invoked by alias); 10 Aug 2013 12:42:04 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12232 invoked by uid 48); 10 Aug 2013 12:42:02 -0000 From: "tilps at hotmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tilps at hotmail dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-08/txt/msg00576.txt.bz2 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 Silly { public: Silly(type *value) { data_ = value; } operator type*() const { return data_; } template operator Silly() const { return Silly(data_); } private: type *data_; }; int main() { Silly a(nullptr); delete a; } Fails giving: test.cc:20:10: error: ambiguous default type conversion from 'Silly' delete a; ^ test.cc:20:10: error: candidate conversions include 'template Silly::operator Silly() const [with other = other; type = int]' test.cc:20:10: error: type 'class Silly' 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 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.