From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20828 invoked by alias); 3 Dec 2002 15:46:06 -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 20805 invoked by uid 71); 3 Dec 2002 15:46:04 -0000 Resent-Date: 3 Dec 2002 15:46:04 -0000 Resent-Message-ID: <20021203154604.20804.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, bangerth@ticam.utexas.edu Received: (qmail 19526 invoked by uid 61); 3 Dec 2002 15:43:36 -0000 Message-Id: <20021203154336.19525.qmail@sources.redhat.com> Date: Tue, 03 Dec 2002 07:46:00 -0000 From: bangerth@ticam.utexas.edu Reply-To: bangerth@ticam.utexas.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/8797: g++ accepts in-class initialization of non-integral static member X-SW-Source: 2002-12/txt/msg00146.txt.bz2 List-Id: >Number: 8797 >Category: c++ >Synopsis: g++ accepts in-class initialization of non-integral static member >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Tue Dec 03 07:46:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Wolfgang Bangerth >Release: unknown-1.0 >Organization: >Environment: 2.95 through 3.3CVS, Linux (but front end matter anyway) >Description: Based on the discussion on PR 8778 (to be found in the audit trail of that report): gcc accepts this although the standard says that only integral _scalars_ can be initialized in-class: ----------------------------- struct A { static const int i[] = { 1,2 }; }; ----------------------------- I _do_ get a warning if I use -pedantic. However, I maintain that I should get an unconditional _error_ instead. On the other hand, if this is a gcc extension, it should - be documented in the manual - generate an _error_ on -pedantic -ansi To make things a little worse: templatizing the class like --------------------------------------- template struct A { static const int i[] = { 1,2 }; }; template struct A<1>; --------------------------------------- yields the following, slightly convoluted error message stating the same content twice in different words: tmp/g> /home/bangerth/bin/gcc-3.3-pre/bin/c++ -pedantic -ansi -c x.cc x.cc:2: warning: ISO C++ forbids initialization of member constant `i' of non-integral type `const int[]' x.cc: In instantiation of `A<1>': x.cc:5: instantiated from here x.cc:2: warning: ISO C++ forbids initialization of member constant `A<1>::i' of non-integral type `const int[2]' >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: