This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/44947] Optimizer doesn't see setjmp()
- From: "cm1 at mumac dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jul 2010 09:15:58 -0000
- Subject: [Bug c/44947] Optimizer doesn't see setjmp()
- References: <bug-44947-19418@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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