From: Richard Henderson Date: Sat, 31 Jul 1999 01:26:09 +0000 (-0700) Subject: Update for label differences. X-Git-Tag: prereleases/libstdc++-2.92~11449 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=47620e09d1e7f800ad5e8e3f2d92c22c2368e1c7;p=thirdparty%2Fgcc.git Update for label differences. From-SVN: r28351 --- diff --git a/gcc/extend.texi b/gcc/extend.texi index f969f65b1892..89a79f563c4e 100644 --- a/gcc/extend.texi +++ b/gcc/extend.texi @@ -295,11 +295,23 @@ Another use of label values is in an interpreter for threaded code. The labels within the interpreter function can be stored in the threaded code for super-fast dispatching. -You can use this mechanism to jump to code in a different function. If -you do that, totally unpredictable things will happen. The best way to +You may not use this mechanism to jump to code in a different function. +If you do that, totally unpredictable things will happen. The best way to avoid this is to store the label address only in automatic variables and never pass it as an argument. +An alternate way to write the above example is + +@example +static const int array[] = @{ &&foo - &&foo, &&bar - &&foo, &&hack - &&foo @}; +goto *(&&foo + array[i]); +@end example + +@noindent +This is more friendly to code living in shared libraries, as it reduces +the number of dynamic relocations that are needed, and by consequence, +allows the data to be read-only. + @node Nested Functions @section Nested Functions @cindex nested functions