From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17581 invoked by alias); 21 Feb 2012 15:53:39 -0000 Received: (qmail 17560 invoked by uid 22791); 21 Feb 2012 15:53:35 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Feb 2012 15:53:20 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52321] poor diagnostic of invalid cast Date: Tue, 21 Feb 2012 15:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-02/txt/msg02084.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52321 --- Comment #3 from Jonathan Wakely 2012-02-21 15:53:10 UTC --- Yep, it's build_static_cast_1 in typeck.c But currently that has no way to store or pass back a message (just a boolean indicating success or failure and the result of the cast) and would need a lot of restructuring. if (target is pointer or reference && source is class type && target is class type && (target is rvalue || source is lvalue) && target is derived from source && can convert && at least as qualified) Your example fails the "target is derived from source" test, but that test doesn't say it failed because the type is incomplete, it just returns false. And the "can convert" step might fail for a number of reasons, but again it just returns a boolean. Modifying that to report different reasons (rather than just evaluating to 'false') is not simple.