This is the mail archive of the gcc-patches@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]

Re: Outdated recommendation?


Chris Lattner wrote:
Is this obsolete?
"If you want a variable to be unaltered by longjmp, and you don't want to
write volatile because old C compilers don't accept it, just take the
address of the variable.

Yes. We shouldn't be worrying about K&R C compilers that don't accept volatile anymore. Also, we shouldn't be trying to explain how to force a variable onto the stack by taking its address, particularly since this is getting harder with tree-ssa and unit-at-time, and will get even harder with IMA.


I added the following patch to remove the obsolete recommendation.

This was tested with an x86-linux make info.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
2004-07-06  James E Wilson  <wilson@specifixinc.com>

	* doc/interface.texi (longjmp and automatic variables): Delete
	paragraph recommending taking the address of a variable.

Index: interface.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/interface.texi,v
retrieving revision 1.5
diff -p -r1.5 interface.texi
*** interface.texi	4 Feb 2004 05:33:12 -0000	1.5
--- interface.texi	6 Jul 2004 17:58:36 -0000
*************** values after a @code{longjmp}.  And this
*** 69,85 ****
  because it is very difficult to restore register variables correctly, and
  one of GCC's features is that it can put variables in registers without
  your asking it to.
- 
- If you want a variable to be unaltered by @code{longjmp}, and you don't
- want to write @code{volatile} because old C compilers don't accept it,
- just take the address of the variable.  If a variable's address is ever
- taken, even if just to compute it and ignore it, then the variable cannot
- go in a register:
- 
- @smallexample
- @{
-   int careful;
-   &careful;
-   @dots{}
- @}
- @end smallexample
--- 69,71 ----

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