Bug report for g++ 2.8.1 (fwd)

Manuel Kessler mlkessle@wpax13.physik.uni-wuerzburg.de
Mon Aug 17 18:49:00 GMT 1998


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


More information about the Gcc-bugs mailing list