From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32767 invoked by alias); 30 Nov 2008 18:52:17 -0000 Received: (qmail 31638 invoked by uid 48); 30 Nov 2008 18:50:54 -0000 Date: Sun, 30 Nov 2008 18:52:00 -0000 Subject: [Bug c++/38335] New: Code warning X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "adam dot c dot scott at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-11/txt/msg02663.txt.bz2 Add warning about modifying an index in a for loop. Without this warning the kind of errors introduced in code are likely to be very difficult to debug (core dump). Example code to reproduce below. Current commandline used to compile: -ansi -pedantic -Wall -O. #include using namespace std; int main(int argc, char** argv) { int loopndx; int indexes[10]; for( loopndx=0 ; loopndx <=10 ; loopndx++) { if (loopndx==5) { loopndx=666666; } cout << indexes[loopndx]; } return (EXIT_SUCCESS); } -- Summary: Code warning Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: adam dot c dot scott at gmail dot com GCC build triplet: dmd GCC host triplet: cyg GCC target triplet: gdc http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38335