Skip to content

Instantly share code, notes, and snippets.

@bradtgmurray
Created October 5, 2009 16:08
Show Gist options
  • Save bradtgmurray/202214 to your computer and use it in GitHub Desktop.
Save bradtgmurray/202214 to your computer and use it in GitHub Desktop.
class A
{
public:
A(int i)
{
printf("A constructor: %u\n", i);
}
};
void const_func()
{
printf("const_func start\n");
const A a(1);
printf("const_func end\n");
}
void static_func()
{
printf("static_func start\n");
static A a(2);
printf("static_func end\n");
}
void static_const_func()
{
printf("static_const_func start\n");
static const A a(3);
printf("static_const_func end\n");
}
int main(char** argv, int argc)
{
printf ("Main start\n");
printf("Round 1\n");
const_func();
static_func();
static_const_func();
printf("Round 2\n");
const_func();
static_func();
static_const_func();
printf("Main end\n");
}
Main start
Round 1
const_func start
A constructor: 1
const_func end
static_func start
A constructor: 2
static_func end
static_const_func start
A constructor: 3
static_const_func end
Round 2
const_func start
A constructor: 1
const_func end
static_func start
static_func end
static_const_func start
static_const_func end
Main end
00401050 :
401050: 55 push %ebp
401051: 89 e5 mov %esp,%ebp
401053: 83 ec 18 sub $0x18,%esp
401056: c7 04 24 00 20 40 00 movl $0x402000,(%esp)
40105d: e8 ce 01 00 00 call 401230
401062: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
401069: 00
40106a: 8d 45 ff lea 0xffffffff(%ebp),%eax
40106d: 89 04 24 mov %eax,(%esp)
401070: e8 2b 04 00 00 call 4014a0
401075: c7 04 24 12 20 40 00 movl $0x402012,(%esp)
40107c: e8 af 01 00 00 call 401230
401081: c9 leave
401082: c3 ret
401083: 90 nop
00401084 :
401084: 55 push %ebp
401085: 89 e5 mov %esp,%ebp
401087: 83 ec 08 sub $0x8,%esp
40108a: c7 04 24 35 20 40 00 movl $0x402035,(%esp)
401091: e8 9a 01 00 00 call 401230
401096: 80 3d 10 30 40 00 00 cmpb $0x0,0x403010
40109d: 75 1b jne 4010ba
40109f: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
4010a6: 00
4010a7: c7 04 24 20 30 40 00 movl $0x403020,(%esp)
4010ae: e8 ed 03 00 00 call 4014a0
4010b3: c6 05 10 30 40 00 01 movb $0x1,0x403010
4010ba: c7 04 24 48 20 40 00 movl $0x402048,(%esp)
4010c1: e8 6a 01 00 00 call 401230
4010c6: c9 leave
4010c7: c3 ret
004010c8 :
4010c8: 55 push %ebp
4010c9: 89 e5 mov %esp,%ebp
4010cb: 83 ec 08 sub $0x8,%esp
4010ce: c7 04 24 59 20 40 00 movl $0x402059,(%esp)
4010d5: e8 56 01 00 00 call 401230
4010da: 80 3d 30 30 40 00 00 cmpb $0x0,0x403030
4010e1: 75 1b jne 4010fe
4010e3: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
4010ea: 00
4010eb: c7 04 24 40 30 40 00 movl $0x403040,(%esp)
4010f2: e8 a9 03 00 00 call 4014a0
4010f7: c6 05 30 30 40 00 01 movb $0x1,0x403030
4010fe: c7 04 24 72 20 40 00 movl $0x402072,(%esp)
401105: e8 26 01 00 00 call 401230
40110a: c9 leave
40110b: c3 ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment