public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* middle-end/10065: gcc/g++ issues error instead of warning on non-ISO array assignment.
@ 2003-03-13 20:36 arthur.baldwin
0 siblings, 0 replies; only message in thread
From: arthur.baldwin @ 2003-03-13 20:36 UTC (permalink / raw)
To: gcc-gnats
>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 "<built-in>"
# 1 "<command line>"
# 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:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-03-13 20:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-13 20:36 middle-end/10065: gcc/g++ issues error instead of warning on non-ISO array assignment arthur.baldwin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).