------- Comment #3 from pinskia at gmail dot com  2010-07-15 09:19 -------
Subject: Re:  Optimizer doesn't see setjmp()



On Jul 15, 2010, at 2:15 AM, "cm1 at mumac dot de" <gcc-bugzi...@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #1 from cm1 at mumac dot de  2010-07-15 09:15 -------
> Sorry, I edited the contents of the precompiler output to make it  
> more readable
> and messed up the auto variable name. Please use this code:
>
> #include <stdlib.h>
> #include <stdio.h>
> #include <setjmp.h>
>
> #define EXC_TRY   1
> #define EXC_CATCH 2
>
> func()
> {
>  const char *p = NULL;                            /*** auto variable  
> ***/


IRRC you need volatile here as defined by the c standard.


>  {
>    jmp_buf exc_jmp_buf;
>    int exc_state;
>
>    if (setjmp(exc_jmp_buf) == 0) {                /*** setjmp() ***/
>      exc_state = EXC_TRY;
>    } else {
>      exc_state = EXC_CATCH;
>    }
>
>    if (exc_state == EXC_TRY) {                    /*** TRY BLOCK ***/
>      p = "some value";
>    }
>
>    if (exc_state == EXC_CATCH) {                  /*** CATCH BLOCK  
> ***/
>      puts(p);
>    }
>  }
> }
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44947
>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44947

Reply via email to