From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4958 invoked by alias); 31 Oct 2010 11:31:16 -0000 Received: (qmail 4948 invoked by uid 22791); 31 Oct 2010 11:31:15 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,MISSING_MID 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; Sun, 31 Oct 2010 11:31:11 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/32402] Error while allocating array of pointers to objects of a pure virtual class X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: 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 Date: Sun, 31 Oct 2010 11:31:00 -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 X-SW-Source: 2010-10/txt/msg02628.txt.bz2 Message-ID: <20101031113100.dgvYoTLgs4UbwJHZOuwfZmtDSbpuPtRdIOarH1VBFJk@z> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32402 --- Comment #11 from Jonathan Wakely 2010-10-31 11:31:01 UTC --- (In reply to comment #10) > Ok, I've read the bug report following a report from a friend, and after > checking various sources I've come to the following conclusion: > > new pure(*[3]) is not valid That's not what the bug report contains though! It's "new (pure(*[3]))" with an extra set of parentheses around the type, so according to the grammar "pure(*[3])" must be parsed as a type-id, there is no initializer > When parsed, "new pure(*[3])" is parsed as "new instance of class pure with > parameter *[3]". Right, and it's not accepted, see comment 5: > - "list = new pure(*[3]);" => does not compile But that's a different case to "new (pure(*[3]))" which is what this PR is about. > Anyway I see no logical reason why one would want to put part of its allocation > into parenthesis. > > "new pure*[3]" should be perfectly acceptable, is easier to read, and is > accepted by GCC without problems. That's beside the point, if the grammar is valid then it should be accepted. > Jonathan Wakely's example with decltype() is non related as decltype() is a new > compiler keyword, which is valid in this context, but has nothing to do with > the original problem. It demonstrates that GCC is happy to allocate an array of pure* using different syntax, and that the syntax works for declaring an automatic variable. > Anyway I believe this bug report should be closed before more people spend > time looking at C++ references for this. I disagree, it's a bug, and the code is accepted by other compilers.