This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Illegal optimization in presence of setjmp
- To: Luc Bouge <bouge at ens-lyon dot fr>
- Subject: Re: Illegal optimization in presence of setjmp
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Mon, 08 Jan 2001 13:31:52 +0000
- Cc: gcc-bugs at gcc dot gnu dot org, Luc dot Bouge at ens-lyon dot fr
- Cc: rearnsha at arm dot com
- Organization: ARM Ltd.
- Reply-To: rearnsha at arm dot com
> Dear gcc-bugs,
>
> In the small program below, the result obtained with no optimization
> and with -O2 are different. Yet, no warning is issued whatsoever.
>
> The test has been run on gcc 2.95.2, Solaris 5.6/7, i386 and sparc
> architectures.
>
>
> ravel% gcc -Wall bug.c -o bug
> ravel% ./bug
> Test 1: i=0
> Test 2: i=1
> Test 3: i=1
> ravel% gcc -Wall -O2 bug.c -o bug
> ravel% ./bug
> Test 1: i=0
> Test 2: i=1
> Test 3: i=0
You need to declare 'i' volatile, otherwise it will be held in a register
that is restored by the longjump.
R.