From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1896 invoked by alias); 13 Mar 2003 20:36:00 -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 1860 invoked by uid 71); 13 Mar 2003 20:36:00 -0000 Resent-Date: 13 Mar 2003 20:36:00 -0000 Resent-Message-ID: <20030313203600.1859.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, arthur.baldwin@gd-ais.com Received: (qmail 8536 invoked by uid 48); 13 Mar 2003 20:30:15 -0000 Message-Id: <20030313203015.8534.qmail@sources.redhat.com> Date: Thu, 13 Mar 2003 20:36:00 -0000 From: arthur.baldwin@gd-ais.com Reply-To: arthur.baldwin@gd-ais.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: middle-end/10065: gcc/g++ issues error instead of warning on non-ISO array assignment. X-SW-Source: 2003-03/txt/msg00781.txt.bz2 List-Id: >Number: 10065 >Category: middle-end >Synopsis: gcc/g++ issues error instead of warning on non-ISO array assignment. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Thu Mar 13 20:36:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Art Baldwin >Release: output from "gcc -v": Reading specs from /opt/gcc-3.2.2/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/specs; Configured with: ../configure --prefix=/opt/gcc-3.2.2; Thread model: posix; gcc version 3.2.2 >Organization: >Environment: output from "uname -a": Linux gca20.gdds.com 2.4.18-18.7.xbigmem #1 SMP Wed Nov 13 18:24:15 EST 2002 i686 unknown >Description: Couldn't compile legacy code that used gcc feature allowing direct array copy. Compiler issued error (not warning) for non-ISO array copy. In same compilation unit, the compiler ignored a typedef using non-ISO variable length array definition. But with -pedantic flag, compiler issues expected warnings for both the array assignment and the variable length array, and compilation completes successfully. No such problem occurs using gcc/g++ 2.95. ==> compilation fails with -Wall, but doesn't seem to care about the variable length array (not even a warning) gcc -Wall -o arrayTest arrayTest.ii arrayTest.cc: In function `int main()': arrayTest.cc:19: ISO C++ forbids assignment of arrays arrayTest.cc:28: ISO C++ forbids assignment of arrays ==> compilation succeeds with warnings on both the array assignment and the variable length array using -Wall -pedantic gcc -Wall -pedantic -o arrayTest arrayTest.ii arrayTest.cc: In function `int main()': arrayTest.cc:19: warning: ISO C++ forbids assignment of arrays arrayTest.cc:28: warning: ISO C++ forbids assignment of arrays arrayTest.cc: In function `void printMatrix(int*, int, int)': arrayTest.cc:38: warning: ISO C++ forbids variable-size array `matrixType' arrayTest.cc:38: warning: ISO C++ forbids variable-size array `matrixType' >How-To-Repeat: Preprocessed source code follows. Removed cout statements, so print routine is a no-op, but it shows that the compiler handles the non-ISO typedef definition of a variable-length array differently than non-ISO array assignment. # 1 "arrayTest.cc" # 1 "" # 1 "" # 1 "arrayTest.cc" void printMatrix(int * matptr, int rows, int cols); using namespace std; int main() { int x[3] = {1,2,3}; int y[3] = {0}; int x2[3][3] = {{1,2,3},{4,5,6},{7,8,9}}; int y2[3][3] = {{0}}; y = x; # 28 "arrayTest.cc" y2 = x2; return 0; } void printMatrix(int * matptr, int rows, int cols) { typedef int matrixType [rows][cols]; # 62 "arrayTest.cc" return; } >Fix: One workaround is to use -pedantic, as illustrated in "Description". >Release-Note: >Audit-Trail: >Unformatted: