From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23386 invoked by alias); 14 Feb 2003 21:22:28 -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 23354 invoked by uid 48); 14 Feb 2003 21:22:28 -0000 Date: Fri, 14 Feb 2003 21:22:00 -0000 Message-ID: <20030214212228.23352.qmail@sources.redhat.com> To: BrainChild@Skyler.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org From: bangerth@dealii.org Reply-To: bangerth@dealii.org, BrainChild@Skyler.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: c++/9666: Arg conversion problem with operator new X-SW-Source: 2003-02/txt/msg00629.txt.bz2 List-Id: Synopsis: Arg conversion problem with operator new State-Changed-From-To: open->analyzed State-Changed-By: bangerth State-Changed-When: Fri Feb 14 21:22:28 2003 State-Changed-Why: Confirmed -- well, sort of, since I am not sure whether this is legal. Here's the code slightly reformatted: ------------------------- #include struct X { operator size_t (); operator size_t () const; }; char *f2 (const X &x) { return new char[x]; } -------------------------- The compiler complains: tmp/g> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc x.cc: In function `char* f2(const X&)': x.cc:8: error: expression in new-declarator must have integral or enumeration type Now, I tend to think that the code is illegal, due to 5.3.4.7: 7 Every constant-expression in a direct-new-declarator shall be an inte- gral constant expression (_expr.const_) and evaluate to a strictly positive value. The expression in a direct-new-declarator shall have integral type (_basic.fundamental_) with a non-negative value. Then, on the other hand, this code compiles: ----------------------- #include struct X { /* operator size_t (); */ operator size_t () const; }; char *f2 (const X &x) { return new char[x]; } ----------------------- I should think that the presence of the second non-const operator shouldn't make a difference since x is a constant reference... Can someone clarify? W. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9666