This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug report for g++ 2.8.1 (fwd)


Hi,

I sent this to the gcc-maintainers, but since the bug shows up in
egcs-1.0.3 on HP as well, I forward it to the egcs folks as well. Perhaps
you could check whether this problem still exists. I'm afraid I can't
currently check the bug on any other platform for egcs.
Thank you very much!

Ciao,
	Manuel

---------- Forwarded message ----------
Date: Fri, 7 Aug 1998 11:31:36 +0200 (METDST)
From: Manuel Kessler <mlkessle@cip.physik.uni-wuerzburg.de>
To: bug-g++@prep.ai.mit.edu
Subject: Bug report for g++ 2.8.1

Good morning,
this is a bug report for G++ 2.8.1, running on a DOS machine with MS-DOS
6.20. The binaries are as provided from DJ Delorie on the local Simtel
mirror.
The problem is that under certain circumstances the compiler moves a struct
in memory via binary copy instead of using a copy constructor. The attached
test program shows this behaviour and is the minimal test case I could make
up. The produced assembler output shows the binary copy between the labels
LCFI5 and LEHB26. Assembler code was produced by
gcc -g -S gccbug.cpp
Using -fno-exceptions or changing the struct to a template doesn't make the
bug go away. In this simple case, optimization does, but only because the
entire struct is optimized away, in my real program it doesn't.
Interestingly enough, the bug doesn't occur if the first initializer is
changed from the variable i to a plain literal 1. Function calls, global or
local variables do all generate the bug, in short everything but a literal.
The only workaround is to construct the struct via default construction and
assign the members separately.

AFAIK, the C++ standard (hurra!) doesn't allow for bitwise copy of structs
in any case but POD's, and S2 isn't a POD because it contains S1, which has
non-trivial constructors and destructors and therefore isn't a POD.

The same bug shows up with egcs 1.0.3 on a HP machine with HP-UX 10.20,
but not with gcc 2.7.2.f.1 on a Sun ULTRA 1 with Solaris 2.5.1.

Could you please have a look at this problem and perhaps fix it for the next
release? Thank you very much for all your efforts and for providing the
community with such excellent products as the gcc compiler suite.

Ciao,
	Manuel

------------------------------------------------------------------------------
Manuel Kessler
PhD Student at the University of Wuerzburg, Germany, Mathematics Department
SNAIL: W"urzburger Str. 14a, D-97218 Gerbrunn, Germany
EMAIL: mlkessle@cip.physik.uni-wuerzburg.de
WWW: http://cip.physik.uni-wuerzburg.de/~mlkessle
#include <assert.h>

struct S1 {
	S1 * self;
	S1() { self=this; }
	S1(S1 const &) { self=this; }
	~S1() { assert(self==this); }
};

struct S2 {
	int i;
	S1 s;
};

S1 s1;

int main() {
	int i=1;
#ifdef NO_BUG
	S2 s2 = { 1, s1 };
#else
	S2 s2 = { i, s1 };
#endif
}
	.file	"gccbug.cpp"
gcc2_compiled.:
___gnu_compiled_cplusplus:
.text
	.def	_S1;	.scl	10;	.type	010;	.size	4;	.endef
	.def	_self;	.val	0;	.scl	8;	.tag	_S1;	.size	4;	.type	030;	.endef
	.def	.eos;	.val	4;	.scl	102;	.tag	_S1;	.size	4;	.endef
	.def	_S1;	.scl	13;	.tag	_S1;	.size	4;	.type	010;	.endef
	.def	_S1;	.scl	13;	.tag	_S1;	.size	4;	.type	010;	.endef
	.def	_S1;	.scl	13;	.tag	_S1;	.size	4;	.type	010;	.endef
	.def	_S1;	.scl	13;	.tag	_S1;	.size	4;	.type	010;	.endef
	.def	_S1;	.scl	13;	.tag	_S1;	.size	4;	.type	010;	.endef
	.def	_S1;	.scl	13;	.tag	_S1;	.size	4;	.type	010;	.endef
LC0:
	.ascii "gccbug.cpp\0"
LC1:
	.ascii "self==this\0"
	.def	_S1;	.scl	13;	.tag	_S1;	.size	4;	.type	010;	.endef
	.def	_S2;	.scl	10;	.type	010;	.size	8;	.endef
	.def	_i;	.val	0;	.scl	8;	.type	04;	.endef
	.def	_s;	.val	4;	.scl	8;	.tag	_S1;	.size	4;	.type	010;	.endef
	.def	.eos;	.val	8;	.scl	102;	.tag	_S2;	.size	8;	.endef
	.def	_S2;	.scl	13;	.tag	_S2;	.size	8;	.type	010;	.endef
	.def	_S1;	.scl	13;	.tag	_S1;	.size	4;	.type	010;	.endef
.globl _s1
.data
	.p2align 2
_s1:
	.space 4
.text
	.def	_S2;	.scl	13;	.tag	_S2;	.size	8;	.type	010;	.endef
	.def	_S2;	.scl	13;	.tag	_S2;	.size	8;	.type	010;	.endef
	.def	_S2;	.scl	13;	.tag	_S2;	.size	8;	.type	010;	.endef
	.def	_S2;	.scl	13;	.tag	_S2;	.size	8;	.type	010;	.endef
	.def	_S2;	.scl	13;	.tag	_S2;	.size	8;	.type	010;	.endef
	.p2align 2
	.def	_main;	.val	_main;	.scl	2;	.type	044;	.endef
.globl _main
_main:
LFB1:
	.def	.bf;	.val	.;	.scl	101;	.line	17;	.endef
	pushl %ebp
LCFI0:
	movl %esp,%ebp
LCFI1:
	subl $20,%esp
LCFI2:
	.def	_i;	.val	-4;	.scl	1;	.type	04;	.endef
	.def	_s2;	.val	-12;	.scl	1;	.tag	_S2;	.size	8;	.type	010;	.endef
	.ln	2
	movl $1,-4(%ebp)
	.ln	6
	movl $0,-20(%ebp)
	movl $0,-16(%ebp)
	movl -4(%ebp),%eax
	movl %eax,-20(%ebp)
	pushl $_s1
LCFI3:
	leal -16(%ebp),%eax
	pushl %eax
LCFI4:
	call ___2S1RC2S1
	addl $8,%esp
LCFI5:
	movl %eax,%eax
	movl -20(%ebp),%edx
	movl %edx,-12(%ebp)
	movl -16(%ebp),%eax
	movl %eax,-8(%ebp)
LEHB26:
LEHE26:
	jmp L27
	.align 2,0x90
L25:
	nop
	.align 2,0x90
L27:
	pushl $2
LCFI6:
	leal -12(%ebp),%eax
	pushl %eax
LCFI7:
	call __$_2S2
	addl $8,%esp
LCFI8:
	xorl %eax,%eax
	jmp L11
	.align 2,0x90
	jmp L28
	.align 2,0x90
LEHB30:
L26:
	pushl $2
LCFI9:
	leal -12(%ebp),%eax
	pushl %eax
LCFI10:
	call __$_2S2
	addl $8,%esp
LCFI11:
	movl $L25,___eh_pc
	call ___throw
	.align 2,0x90
LEHE30:
	jmp L31
	.align 2,0x90
L29:
	nop
	.align 2,0x90
L31:
L30:
	call _terminate__Fv
	.align 2,0x90
L28:
	.ln	8
L11:
	leave
	ret
	.def	.ef;	.val	.;	.scl	101;	.line	8;	.endef
	.def	_main;	.val	.;	.scl	-1;	.endef
LFE1:
	.p2align 2
	.def	__GLOBAL_$D$s1;	.val	__GLOBAL_$D$s1;	.scl	2;	.type	041;	.endef
.globl __GLOBAL_$D$s1
__GLOBAL_$D$s1:
LFB2:
	.def	.bf;	.val	.;	.scl	101;	.line	24;	.endef
	pushl %ebp
LCFI12:
	movl %esp,%ebp
LCFI13:
	pushl $2
LCFI14:
	pushl $_s1
LCFI15:
	call __$_2S1
	addl $8,%esp
LCFI16:
L32:
	leave
	ret
	.def	.ef;	.val	.;	.scl	101;	.line	1;	.endef
	.def	__GLOBAL_$D$s1;	.val	.;	.scl	-1;	.endef
LFE2:
	.section .dtor
	.long	__GLOBAL_$D$s1
.text
	.p2align 2
	.def	__GLOBAL_$I$s1;	.val	__GLOBAL_$I$s1;	.scl	2;	.type	041;	.endef
.globl __GLOBAL_$I$s1
__GLOBAL_$I$s1:
LFB3:
	.def	.bf;	.val	.;	.scl	101;	.line	24;	.endef
	pushl %ebp
LCFI17:
	movl %esp,%ebp
LCFI18:
	pushl $_s1
LCFI19:
	call ___2S1
	addl $4,%esp
LCFI20:
L33:
	leave
	ret
	.def	.ef;	.val	.;	.scl	101;	.line	1;	.endef
	.def	__GLOBAL_$I$s1;	.val	.;	.scl	-1;	.endef
LFE3:
	.section .ctor
	.long	__GLOBAL_$I$s1
.text
	.p2align 2
	.def	__$_2S2;	.val	__$_2S2;	.scl	3;	.type	041;	.endef
__$_2S2:
LFB4:
	.def	.bf;	.val	.;	.scl	101;	.line	22;	.endef
	.def	_this;	.val	8;	.scl	9;	.tag	_S2;	.size	8;	.type	030;	.endef
	.def	___in_chrg;	.val	12;	.scl	9;	.type	04;	.endef
	.def	_this;	.val	6;	.scl	4;	.tag	_S2;	.size	8;	.type	030;	.endef
	.def	___in_chrg;	.val	3;	.scl	4;	.type	04;	.endef
	pushl %ebp
LCFI21:
	movl %esp,%ebp
LCFI22:
	pushl %esi
LCFI23:
	pushl %ebx
LCFI24:
	movl 8(%ebp),%esi
	movl 12(%ebp),%ebx
L13:
	pushl $2
LCFI25:
	leal 4(%esi),%eax
	pushl %eax
LCFI26:
	call __$_2S1
	addl $8,%esp
LCFI27:
	movl %ebx,%eax
	andl $1,%eax
	testl %eax,%eax
	je L15
	pushl %esi
LCFI28:
	call ___builtin_delete
	addl $4,%esp
LCFI29:
	jmp L15
	.align 2,0x90
L14:
L15:
L12:
	leal -8(%ebp),%esp
	popl %ebx
	popl %esi
	leave
	ret
	.def	.ef;	.val	.;	.scl	101;	.line	1;	.endef
	.def	__$_2S2;	.val	.;	.scl	-1;	.endef
LFE4:
	.p2align 2
	.def	__$_2S1;	.val	__$_2S1;	.scl	3;	.type	041;	.endef
__$_2S1:
LFB5:
	.def	.bf;	.val	.;	.scl	101;	.line	7;	.endef
	.def	_this;	.val	8;	.scl	9;	.tag	_S1;	.size	4;	.type	030;	.endef
	.def	___in_chrg;	.val	12;	.scl	9;	.type	04;	.endef
	.def	_this;	.val	6;	.scl	4;	.tag	_S1;	.size	4;	.type	030;	.endef
	.def	___in_chrg;	.val	3;	.scl	4;	.type	04;	.endef
	pushl %ebp
LCFI30:
	movl %esp,%ebp
LCFI31:
	pushl %esi
LCFI32:
	pushl %ebx
LCFI33:
	movl 8(%ebp),%esi
	movl 12(%ebp),%ebx
	cmpl %esi,(%esi)
	je L8
	pushl $7
LCFI34:
	pushl $LC0
LCFI35:
	pushl $LC1
LCFI36:
	call ___dj_assert
	addl $12,%esp
LCFI37:
	.align 2,0x90
	jmp L6
	.align 2,0x90
L7:
L6:
L8:
	movl %ebx,%eax
	andl $1,%eax
	testl %eax,%eax
	je L10
	pushl %esi
LCFI38:
	call ___builtin_delete
	addl $4,%esp
LCFI39:
	jmp L10
	.align 2,0x90
L9:
L10:
L5:
	leal -8(%ebp),%esp
	popl %ebx
	popl %esi
	leave
	ret
	.def	.ef;	.val	.;	.scl	101;	.line	1;	.endef
	.def	__$_2S1;	.val	.;	.scl	-1;	.endef
LFE5:
	.p2align 2
	.def	___2S1RC2S1;	.val	___2S1RC2S1;	.scl	3;	.tag	_S1;	.size	4;	.type	0150;	.endef
___2S1RC2S1:
LFB6:
	.def	.bf;	.val	.;	.scl	101;	.line	6;	.endef
	.def	_this;	.val	8;	.scl	9;	.tag	_S1;	.size	4;	.type	030;	.endef
	.def	_this;	.val	1;	.scl	4;	.tag	_S1;	.size	4;	.type	030;	.endef
	pushl %ebp
LCFI40:
	movl %esp,%ebp
LCFI41:
	movl 8(%ebp),%ecx
	movl 12(%ebp),%edx
	movl %ecx,(%ecx)
L4:
	movl %ecx,%eax
	jmp L3
	.align 2,0x90
L3:
	leave
	ret
	.def	.ef;	.val	.;	.scl	101;	.line	1;	.endef
	.def	___2S1RC2S1;	.val	.;	.scl	-1;	.endef
LFE6:
	.p2align 2
	.def	___2S1;	.val	___2S1;	.scl	3;	.tag	_S1;	.size	4;	.type	0150;	.endef
___2S1:
LFB7:
	.def	.bf;	.val	.;	.scl	101;	.line	5;	.endef
	.def	_this;	.val	8;	.scl	9;	.tag	_S1;	.size	4;	.type	030;	.endef
	.def	_this;	.val	2;	.scl	4;	.tag	_S1;	.size	4;	.type	030;	.endef
	pushl %ebp
LCFI42:
	movl %esp,%ebp
LCFI43:
	movl 8(%ebp),%edx
	movl %edx,(%edx)
L2:
	movl %edx,%eax
	jmp L1
	.align 2,0x90
L1:
	leave
	ret
	.def	.ef;	.val	.;	.scl	101;	.line	1;	.endef
	.def	___2S1;	.val	.;	.scl	-1;	.endef
LFE7:
	.section .gcc_except_table
	.p2align 2
___EXCEPTION_TABLE__:
	.long LEHB26
	.long LEHE26
	.long L26

	.long LEHB30
	.long LEHE30
	.long L30

___EXCEPTION_END__:
	.long -1
	.long -1
	.long -1

.text
	.def	_s1;	.val	_s1;	.scl	2;	.tag	_S1;	.size	4;	.type	010;	.endef

	.section .eh_frame
___FRAME_BEGIN__:
	.long LECIE1-LSCIE1

LSCIE1:
	.long 0

		.byte	0x1
	.ascii "eh\0"

	.long ___EXCEPTION_TABLE__

		.byte	0x1
		.byte	0x7c
		.byte	0x8
		.byte	0xc
		.byte	0x5
		.byte	0x4
		.byte	0x88
		.byte	0x1
	.p2align 2
LECIE1:
	.long LEFDE1-LSFDE1

LSFDE1:
	.long LSFDE1-___FRAME_BEGIN__

	.long LFB1

	.long LFE1-LFB1

		.byte	0x4
	.long LCFI0-LFB1

		.byte	0xe
		.byte	0x8
		.byte	0x84
		.byte	0x2
		.byte	0x4
	.long LCFI1-LCFI0

		.byte	0xd
		.byte	0x4
		.byte	0x4
	.long LCFI3-LCFI1

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI4-LCFI3

		.byte	0x2e
		.byte	0x8
		.byte	0x4
	.long LCFI5-LCFI4

		.byte	0x2e
		.byte	0x0
		.byte	0x4
	.long LCFI6-LCFI5

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI7-LCFI6

		.byte	0x2e
		.byte	0x8
		.byte	0x4
	.long LCFI8-LCFI7

		.byte	0x2e
		.byte	0x0
		.byte	0x4
	.long LCFI9-LCFI8

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI10-LCFI9

		.byte	0x2e
		.byte	0x8
		.byte	0x4
	.long LCFI11-LCFI10

		.byte	0x2e
		.byte	0x0
	.p2align 2
LEFDE1:
	.long LEFDE3-LSFDE3

LSFDE3:
	.long LSFDE3-___FRAME_BEGIN__

	.long LFB2

	.long LFE2-LFB2

		.byte	0x4
	.long LCFI12-LFB2

		.byte	0xe
		.byte	0x8
		.byte	0x84
		.byte	0x2
		.byte	0x4
	.long LCFI13-LCFI12

		.byte	0xd
		.byte	0x4
		.byte	0x4
	.long LCFI14-LCFI13

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI15-LCFI14

		.byte	0x2e
		.byte	0x8
		.byte	0x4
	.long LCFI16-LCFI15

		.byte	0x2e
		.byte	0x0
	.p2align 2
LEFDE3:
	.long LEFDE5-LSFDE5

LSFDE5:
	.long LSFDE5-___FRAME_BEGIN__

	.long LFB3

	.long LFE3-LFB3

		.byte	0x4
	.long LCFI17-LFB3

		.byte	0xe
		.byte	0x8
		.byte	0x84
		.byte	0x2
		.byte	0x4
	.long LCFI18-LCFI17

		.byte	0xd
		.byte	0x4
		.byte	0x4
	.long LCFI19-LCFI18

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI20-LCFI19

		.byte	0x2e
		.byte	0x0
	.p2align 2
LEFDE5:
	.long LEFDE7-LSFDE7

LSFDE7:
	.long LSFDE7-___FRAME_BEGIN__

	.long LFB4

	.long LFE4-LFB4

		.byte	0x4
	.long LCFI21-LFB4

		.byte	0xe
		.byte	0x8
		.byte	0x84
		.byte	0x2
		.byte	0x4
	.long LCFI22-LCFI21

		.byte	0xd
		.byte	0x4
		.byte	0x4
	.long LCFI23-LCFI22

		.byte	0x86
		.byte	0x3
		.byte	0x4
	.long LCFI24-LCFI23

		.byte	0x83
		.byte	0x4
		.byte	0x4
	.long LCFI25-LCFI24

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI26-LCFI25

		.byte	0x2e
		.byte	0x8
		.byte	0x4
	.long LCFI27-LCFI26

		.byte	0x2e
		.byte	0x0
		.byte	0x4
	.long LCFI28-LCFI27

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI29-LCFI28

		.byte	0x2e
		.byte	0x0
	.p2align 2
LEFDE7:
	.long LEFDE9-LSFDE9

LSFDE9:
	.long LSFDE9-___FRAME_BEGIN__

	.long LFB5

	.long LFE5-LFB5

		.byte	0x4
	.long LCFI30-LFB5

		.byte	0xe
		.byte	0x8
		.byte	0x84
		.byte	0x2
		.byte	0x4
	.long LCFI31-LCFI30

		.byte	0xd
		.byte	0x4
		.byte	0x4
	.long LCFI32-LCFI31

		.byte	0x86
		.byte	0x3
		.byte	0x4
	.long LCFI33-LCFI32

		.byte	0x83
		.byte	0x4
		.byte	0x4
	.long LCFI34-LCFI33

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI35-LCFI34

		.byte	0x2e
		.byte	0x8
		.byte	0x4
	.long LCFI36-LCFI35

		.byte	0x2e
		.byte	0xc
		.byte	0x4
	.long LCFI37-LCFI36

		.byte	0x2e
		.byte	0x0
		.byte	0x4
	.long LCFI38-LCFI37

		.byte	0x2e
		.byte	0x4
		.byte	0x4
	.long LCFI39-LCFI38

		.byte	0x2e
		.byte	0x0
	.p2align 2
LEFDE9:
	.long LEFDE11-LSFDE11

LSFDE11:
	.long LSFDE11-___FRAME_BEGIN__

	.long LFB6

	.long LFE6-LFB6

		.byte	0x4
	.long LCFI40-LFB6

		.byte	0xe
		.byte	0x8
		.byte	0x84
		.byte	0x2
		.byte	0x4
	.long LCFI41-LCFI40

		.byte	0xd
		.byte	0x4
	.p2align 2
LEFDE11:
	.long LEFDE13-LSFDE13

LSFDE13:
	.long LSFDE13-___FRAME_BEGIN__

	.long LFB7

	.long LFE7-LFB7

		.byte	0x4
	.long LCFI42-LFB7

		.byte	0xe
		.byte	0x8
		.byte	0x84
		.byte	0x2
		.byte	0x4
	.long LCFI43-LCFI42

		.byte	0xd
		.byte	0x4
	.p2align 2
LEFDE13:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]