リスト31 リスト32 リスト33 リスト34


〔リスト31〕ANCI C準拠のコードの例(test65.c)
	#include <stdio.h>
	union foo { int i; double d; };
	int x;
	double y;
	int main(void)
	{
	 union foo u;
	 x = 10;
	 u = (union foo) x;
	 return;
	}


〔リスト32〕test65.cから生成されたアセンブラ(test65.s)
	 .file "test65.c"
	 .version "01.01"
	gcc2_compiled.:
	.text
	 .align 4
	.globl main
	 .type  main,@function
	main:
	 pushl %ebp
	 movl %esp,%ebp
	 subl $24,%esp
	 movl $10,x
	 movl x,%eax
	 movl %eax,-8(%ebp)
	 movl %edx,-4(%ebp)
	 jmp .L2
	 .p2align 4,,7
	.L2:
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe1:
	 .size  main,.Lfe1-main
	 .comm x,4,4
	 .comm y,8,8
	 .ident "GCC: (GNU) 2.95.3 20010315 (release)"


〔リスト33〕共用体へのキャストを使用する例(test66.c)
	#include <stdio.h>
	union foo { int i; double d; };
	int x;
	double y;
	int main(void)
	{
	 union foo u;
	 x = 10;
	 u.i = x;
	 return;
	}


〔リスト34〕test66.cから生成されたアセンブラ(test66.s)
	 .file "test66.c"
	 .version "01.01"
	gcc2_compiled.:
	.text
	 .align 4
	.globl main
	 .type  main,@function
	main:
	 pushl %ebp
	 movl %esp,%ebp
	 subl $24,%esp
	 movl $10,x
	 movl x,%eax
	 movl %eax,-8(%ebp)
	 jmp .L2
	 .p2align 4,,7
	.L2:
	 movl %ebp,%esp
	 popl %ebp
	 ret
	.Lfe1:
	 .size  main,.Lfe1-main
	 .comm x,4,4
	 .comm y,8,8
	 .ident "GCC: (GNU) 2.95.3 20010315 (release)"