Исходный код на C++

class Alpha {
public:
	int data_alpha;
	virtual void func_alpha () = 0;
};
 
class Beta {
public:
	int data_beta;
	virtual void func_beta () = 0;
};
 
class Gamma : public Alpha, public Beta {
public:
	int data_gamma;
	virtual void func_alpha () {
		asm ("# func_alpha");
	}
	virtual void func_beta () {
		asm ("# func_beta");
	}
	virtual void func_gamma () {
		asm ("# func_gamma");
	}
};
 
int func ()
{
	static Gamma x;
 
	x.data_alpha = 1;
	x.data_beta = 2;
	x.data_gamma = 3;
	return sizeof (x);
}

Параметры компиляции

gcc -O -fno-rtti -fno-exceptions -Wno-non-virtual-dtor -S gamma.cpp

Результат на ассемблере

	.file	"gamma.cpp"
	.section	.gnu.linkonce.t._ZN5Gamma10func_alphaEv,"ax",@progbits
	.align 2
	.weak	_ZN5Gamma10func_alphaEv
	.type	_ZN5Gamma10func_alphaEv, @function
_ZN5Gamma10func_alphaEv:
	pushl	%ebp
	movl	%esp, %ebp
#APP
	# func_alpha
#NO_APP
	popl	%ebp
	ret
	.size	_ZN5Gamma10func_alphaEv, .-_ZN5Gamma10func_alphaEv
	.section	.gnu.linkonce.t._ZN5Gamma9func_betaEv,"ax",@progbits
	.align 2
	.weak	_ZThn8_N5Gamma9func_betaEv
	.type	_ZThn8_N5Gamma9func_betaEv, @function
_ZThn8_N5Gamma9func_betaEv:
	addl	$-8, 4(%esp)
	jmp	.LTHUNK0
	.size	_ZThn8_N5Gamma9func_betaEv, .-_ZThn8_N5Gamma9func_betaEv
	.align 2
	.weak	_ZN5Gamma9func_betaEv
	.type	_ZN5Gamma9func_betaEv, @function
_ZN5Gamma9func_betaEv:
	pushl	%ebp
	movl	%esp, %ebp
#APP
	# func_beta
#NO_APP
	popl	%ebp
	ret
	.size	_ZN5Gamma9func_betaEv, .-_ZN5Gamma9func_betaEv
	.section	.gnu.linkonce.t._ZN5Gamma10func_gammaEv,"ax",@progbits
	.align 2
	.weak	_ZN5Gamma10func_gammaEv
	.type	_ZN5Gamma10func_gammaEv, @function
_ZN5Gamma10func_gammaEv:
	pushl	%ebp
	movl	%esp, %ebp
#APP
	# func_gamma
#NO_APP
	popl	%ebp
	ret
	.size	_ZN5Gamma10func_gammaEv, .-_ZN5Gamma10func_gammaEv
	.text
	.align 2
.globl _Z4funcv
	.type	_Z4funcv, @function
_Z4funcv:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	cmpb	$0, _ZGVZ4funcvE1x
	jne	.L8
	movl	$_ZGVZ4funcvE1x, (%esp)
	call	__cxa_guard_acquire
	testl	%eax, %eax
	je	.L8
	movl	$_ZTV5Gamma+8, _ZZ4funcvE1x
	movl	$_ZTV5Gamma+28, _ZZ4funcvE1x+8
	movl	$_ZGVZ4funcvE1x, (%esp)
	call	__cxa_guard_release
.L8:
	movl	$1, _ZZ4funcvE1x+4
	movl	$2, _ZZ4funcvE1x+12
	movl	$3, _ZZ4funcvE1x+16
	movl	$20, %eax
	leave
	ret
	.size	_Z4funcv, .-_Z4funcv
	.local	_ZGVZ4funcvE1x
	.comm	_ZGVZ4funcvE1x,8,8
	.local	_ZZ4funcvE1x
	.comm	_ZZ4funcvE1x,20,4
	.weak	_ZTV5Gamma
	.section	.gnu.linkonce.r._ZTV5Gamma,"a",@progbits
	.align 32
	.type	_ZTV5Gamma, @object
	.size	_ZTV5Gamma, 32
_ZTV5Gamma:
	.long	0
	.long	0
	.long	_ZN5Gamma10func_alphaEv
	.long	_ZN5Gamma9func_betaEv
	.long	_ZN5Gamma10func_gammaEv
	.long	-8
	.long	0
	.long	_ZThn8_N5Gamma9func_betaEv
	.weak	_ZTV5Alpha
	.section	.gnu.linkonce.r._ZTV5Alpha,"a",@progbits
	.align 8
	.type	_ZTV5Alpha, @object
	.size	_ZTV5Alpha, 12
_ZTV5Alpha:
	.long	0
	.long	0
	.long	__cxa_pure_virtual
	.weak	_ZTV4Beta
	.section	.gnu.linkonce.r._ZTV4Beta,"a",@progbits
	.align 8
	.type	_ZTV4Beta, @object
	.size	_ZTV4Beta, 12
_ZTV4Beta:
	.long	0
	.long	0
	.long	__cxa_pure_virtual
	.set	.LTHUNK0,_ZN5Gamma9func_betaEv
	.ident	"GCC: (GNU) 4.1.1"
	.section	.note.GNU-stack,"",@progbits
 
proj/lang/gamma-cpp.txt · Последние изменения: 2006/06/14 07:07
 
Copyright (C) 1996-2013 Serge Vakulenko
serge@vak.ru