This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
-fcheck-stack and goto
- From: "Ulrich Weigand" <Ulrich dot Weigand at de dot ibm dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 24 Apr 2003 14:25:45 +0200
- Subject: -fcheck-stack and goto
- Sensitivity:
Hello,
we've seen problems compiling code that uses 'goto' with the
-fcheck-stack switch.
Code that jumps *into* the scope of a local variable:
void test (void)
{
goto label;
{
int var[1000];
label:
;
}
}
is valid in both C and C++ if the variable is not dynamically sized
and has no initializer (or constructor).
However, when compiling with -fcheck-stack and the size of 'var'
exceeds the 'small' variable limit, the compiler converts this
declaration implicitly to a dynamic stack allocation. In doing
this, the 'goto' becomes invalid:
test.i: In function `test':
test.i:10: error: label `label' used before containing binding contour
While I can understand how this would come about seeing the way
-fcheck-stack is implemented, it would appear undesirable to have
the compiler reject valid code just because -fcheck-stack was given.
Is there some way this can be fixed? At least this restriction
should be documented ...
Mit freundlichen Gruessen / Best Regards
Ulrich Weigand
--
Dr. Ulrich Weigand
Linux for S/390 Design & Development
IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
Phone: +49-7031/16-3727 --- Email: Ulrich dot Weigand at de dot ibm dot com