This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1803: usage of variable declaration inside "for" loop corrupts other variable on stack



>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:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]