This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/1803: usage of variable declaration inside "for" loop corrupts other variable on stack
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/1803: usage of variable declaration inside "for" loop corrupts other variable on stack
- From: joseph dot barreca at transport dot alstom dot com
- Date: 29 Jan 2001 13:36:17 -0000
- Reply-To: joseph dot barreca at transport dot alstom dot com
>Number: 1803
>Category: c++
>Synopsis: usage of variable declaration inside "for" loop corrupts other variable on stack
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Jan 29 05:46:04 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Joe Barreca
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Red Hat Linux release 6.2, on Pentium III
>Description:
Usage of a simple variable declaration inside a "for" loop results in the corruption of an independent local variable's contents. This appears to occur when the for loop is exited (on the loss of scope of the vaiable declaration). Thus, would appear to be inconsistent stack access.
>How-To-Repeat:
Test file jdb1.C, contained in attached .ii file.
Compile and build as follows:
g++ -Wall -o jdb1 -v -save-temps jdb1.C
(note - got no complaints from -Wall)
>Fix:
Work around is to remove usage of such "embedded declarations" from all code (yuk).
>Release-Note:
>Audit-Trail:
>Unformatted: