Behaviour of setjmp/longjmp and registers

Chris Torek chris at mimsy.UUCP
Sat Jan 21 07:11:21 AEST 1989


In article <25 at torsqnt.UUCP> david at torsqnt.UUCP (David Haynes) writes:
>What should be the result of running the following program?

[example of register variables and longjmp deleted]

>Sequent, Ultrix and Vax C give results of j = 1, j = 4.
>Gcc gives a result of j = 1, j = 1.
>What does the ANSI standard say about this?

The ANSI standard says that register variables, like all other
automatic variables, must be declared `volatile' for you to be able to
assume the output will be `j = 1, j = 4'.  Of course, since there is no
`volatile' qualifier in most existing C compilers, in practise this
means that you must not declare variables as register in order to count
on them (so that `#define volatile /*empty*/' will work).

(I guess you were not reading when I posted this the last two or three
times last month. . . .)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list