invalid init of static var

This commit is contained in:
MITSUNARI Shigeo 2012-12-02 21:28:30 +09:00
parent d548d02e2c
commit 5f696277f7
4 changed files with 26 additions and 14 deletions

View file

@ -1,17 +1,23 @@
#include "lib.h"
#include <xbyak/xbyak.h>
struct Code : public Xbyak::CodeGenerator {
Code()
{
mov(eax, 5);
printf("Code:%s\n", eax.toString());
ret();
}
};
int ret123()
void init()
try
{
static bool init = true;
printf("in lib_test %d\n", init);
if (!init) return;
init = false;
static Code code;
int (*f)() = (int (*)())code.getCode();
return f();
} catch (const Xbyak::Error& e) {
printf("err=%s\n", Xbyak::ConvertErrorToString(e));
}