From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6322 invoked by alias); 7 Sep 2007 23:50:37 -0000 Received: (qmail 6265 invoked by uid 48); 7 Sep 2007 23:50:24 -0000 Date: Fri, 07 Sep 2007 23:50:00 -0000 Message-ID: <20070907235024.6263.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/26698] [4.0/4.1/4.2/4.3 Regression] g++ accepts const-incorrect code due to conversion function In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mmitchel at gcc dot gnu dot org" 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: 2007-09/txt/msg00621.txt.bz2 ------- Comment #10 from mmitchel at gcc dot gnu dot org 2007-09-07 23:50 ------- It looks to me that the change I made in Comment #5 was just an optimization; the warning was already conditionalized on warn_conversion. I just short-circuited the checking sooner. Declaring the conversion function is not illegal, so I think it's OK that we only warn conditionally. It's true that we should never use the conversion function. The error we're getting now is just a consequence of the body of the conversion function; if we put "return *new X" in there, it would compile file, and we probably wouldn't get an error about the program, even though it's still invalid. So, I do think that there's a bug somewhere; we shouldn't be considering this conversion operator when calling add_one. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26698