From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32325 invoked by alias); 11 Feb 2003 20:46:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 32224 invoked by uid 71); 11 Feb 2003 20:46:00 -0000 Resent-Date: 11 Feb 2003 20:46:00 -0000 Resent-Message-ID: <20030211204600.32222.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, BrainChild@Skyler.com Received: (qmail 30599 invoked by uid 48); 11 Feb 2003 20:44:31 -0000 Message-Id: <20030211204431.30598.qmail@sources.redhat.com> Date: Tue, 11 Feb 2003 20:46:00 -0000 From: BrainChild@Skyler.com Reply-To: BrainChild@Skyler.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/9666: Arg conversion problem with operator new X-SW-Source: 2003-02/txt/msg00505.txt.bz2 List-Id: >Number: 9666 >Category: c++ >Synopsis: Arg conversion problem with operator new >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Feb 11 20:46:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Don Stauffer >Release: 3.2 >Organization: >Environment: Cygwin under Windows 2000 Professional >Description: g++ produces error "size in array new must have integral type" if you use new[] with an argument of a class with two integral conversion operators which are identical exception one is a const method. The conversion works if used to pass the class object as a size_t function argument, and works with new if you remove either one of the conversion operators. >How-To-Repeat: #include struct X { operator size_t () { return 2; } operator size_t () const { return 3; } }; char *f1 ( size_t n ) { return new char[n]; } char *f2 ( const X &x ) { return new char[x]; } int main (void) { } /* $ g t.cpp -ot t.cpp: In function `char* f2(const X&)': t.cpp:11: size in array new must have integral type */ >Fix: Workaround: Call a function which converts the argument and allocates the memory rather than calling new directly. >Release-Note: >Audit-Trail: >Unformatted: