This is the mail archive of the gcc@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]
Other format: [Raw text]

-fcheck-stack and goto


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


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