test for unorderd init
This commit is contained in:
parent
be5d47c144
commit
a57fdb0f10
4 changed files with 35 additions and 2 deletions
27
test/lib.h
27
test/lib.h
|
@ -1,6 +1,27 @@
|
|||
#pragma once
|
||||
#include <stdio.h>
|
||||
|
||||
struct Reg {
|
||||
int r_;
|
||||
Reg(int r) : r_(r) {}
|
||||
};
|
||||
|
||||
inline const Reg& getReg0() { static const Reg r(0); return r; }
|
||||
inline const Reg& getReg1() { static const Reg r(1); return r; }
|
||||
inline const Reg& getReg2() { static const Reg r(2); return r; }
|
||||
|
||||
static const Reg& r0 = getReg0();
|
||||
static const Reg& r1 = getReg1();
|
||||
static const Reg& r2 = getReg2();
|
||||
|
||||
inline void putReg()
|
||||
{
|
||||
puts("putReg");
|
||||
printf("r0=%p, %d\n", &r0, r0.r_);
|
||||
printf("r0=%p, %d\n", &r0, r1.r_);
|
||||
printf("r0=%p, %d\n", &r0, r2.r_);
|
||||
}
|
||||
|
||||
struct A {
|
||||
int a;
|
||||
A()
|
||||
|
@ -30,11 +51,13 @@ typedef XT<0> X;
|
|||
|
||||
void init();
|
||||
|
||||
static struct Init {
|
||||
struct Init {
|
||||
Init()
|
||||
{
|
||||
puts("Init");
|
||||
init();
|
||||
putReg();
|
||||
}
|
||||
} s_init;
|
||||
};
|
||||
static Init s_init;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue