This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21667] New: misleading warning about array subscription
- From: "gdr at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 May 2005 19:47:52 -0000
- Subject: [Bug c++/21667] New: misleading warning about array subscription
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
GCC (g++) emits a warning (-Wall) for the following code
% cat ary.C && g++ -Wall ary.C
int main()
{
int ary[256] = { 0 };
return ary['a'];
}
ary.C: In function 'int main()':
ary.C:4: warning: array subscript has type 'char'
The diagnostic is not helpful because the index is positive
(all character constants from the basic character set have
nonnegative values).
The warning should be emitted only if the index is unkonwn (at
compile time) and has type 'char'.
-- Gaby
--
Summary: misleading warning about array subscription
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gdr at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: plateform independent
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21667