From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27856 invoked by alias); 8 Feb 2002 14:26:08 -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 27767 invoked by uid 71); 8 Feb 2002 14:26:06 -0000 Resent-Date: 8 Feb 2002 14:26:06 -0000 Resent-Message-ID: <20020208142606.27766.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Falk Hueffner Received:(qmail 24415 invoked from network); 8 Feb 2002 14:23:28 -0000 Received: from unknown (HELO mx1.informatik.uni-tuebingen.de) (134.2.12.5) by sources.redhat.com with SMTP; 8 Feb 2002 14:23:28 -0000 Received: from ogeima.informatik.uni-tuebingen.de (ogeima [134.2.15.67]) by mx1.informatik.uni-tuebingen.de (Postfix) with ESMTP id 5C14D4AD for ; Fri, 8 Feb 2002 15:23:26 +0100 (MET) Received: (from hueffner@localhost) by ogeima.informatik.uni-tuebingen.de (8.10.2+Sun/8.10.2) id g18ENPb10474; Fri, 8 Feb 2002 15:23:25 +0100 (MET) Message-Id:<200202081423.g18ENPb10474@ ogeima.informatik.uni-tuebingen.de> Date: Fri, 08 Feb 2002 06:26:00 -0000 From: Falk Hueffner To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:3.113 Subject: c++/5635: no initialization for array new with initializer X-SW-Source: 2002-02/txt/msg00206.txt.bz2 List-Id: >Number: 5635 >Category: c++ >Synopsis: no initialization for array new with initializer >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Feb 08 06:26:03 PST 2002 >Closed-Date: >Last-Modified: >Originator: >Release: 3.0 >Organization: >Environment: System: SunOS ogeima 5.8 Generic_108528-12 sun4u sparc SUNW,Sun-Blade-100 Architecture: sun4 host: sparc-sun-solaris2.8 build: sparc-sun-solaris2.8 target: sparc-sun-solaris2.8 configured with: ../gcc-3.0/configure --prefix=/afs/informatik.uni-tuebingen.de/sun4x_58/gcc-3.0 >Description: g++ accepts the following construct: int* p = new int[10](666); which is ill-formed (according to my reading of the standard, and g++ seems to know that, since it warns when giving -ansi). However, it does not follow the "obvoius" semantics of this statement (to initialize all array members with the initializer, analogous to new int[10]()), but instead doesn't initialize at all. It doesn't even check for the type of the "initializer", new int[10](std::cout) is also accepted >How-To-Repeat: hueffner@ogeima:~% cat foo.cc #include int main() { int* p = new int[10000](666); for (int i = 0; i < 10000; ++i) std::cout << p[i] << ' '; std::cout << std::endl; } hueffner@ogeima:~% g++ foo.cc hueffner@ogeima:~% ./a.out 0 0 0 0 0 0 0 0 0 0 0 [...] 0 0 170800 0 3 0 0 0 [...] >Fix: g++ should either reject this construct or give it a sensible semantics. >Release-Note: >Audit-Trail: >Unformatted: