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

[Bug c/44947] Optimizer doesn't see setjmp()



------- 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 ***/
  {
    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


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