From: Felix=Schmitt%TECHNIK%CE@bangate.COMpaq.COM
Subject: g++ bug with virtual funktions
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 5 Jan 1993 16:45:28 GMT

The size of the Message Text is 10747(> 6K), So it is kept in the First Attachmen

*****  ATTACHMENT: mailman.txt *****

I think I found a bug in the g++ part of the gnu compiler.
We have Banyan Mail System and I hope everything gets to you. If not please let 
me know.

I have included a short c++ listing which reproduces the bug,
the assembler output and the output from the "-v" option given to the compiler.
The source isn't very useful because I have striped off all of the unnecessary 
source code.  I wanted to reproduce the bug in a short example.

The command line I have used was:
	c++ -o bar -v -g -O bar.c 2>verbose.out

Optimization does not matter for the bug. The bug also appears if I don't use
the -O option.

When running this program I get the message:
	Illegal instruction(coredump)
but I extracted this example from a much bigger program and there I get a
memory fault.

I think "_vptr.foo" for the variable "t" in "func" isn't set correctly, but
afterwards it is needed to call "ins".

Now to my environment:
I have a COMPAQ Systempro with SCO UNIX 3.2 Version 4 with the Multiprocessor  
eXtension MPX 2.0.
The version of GCC is 2.3.3 and I didn't change anything at the source code.
I gave i486-*-sco3.2v4 to the configure command.

I hope I supplied you with all the information you need. If not feel free to 
contact me.
My mail address is:
	Felix=Schmitt%TECHNIK%CE@bangate.compaq.com

Felix


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  README.bug bar.c bar.s verbose.out
# Wrapped by felix@boscop on Tue Jan  5 10:36:57 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README.bug' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README.bug'\"
else
echo shar: Extracting \"'README.bug'\" \(1296 characters\)
sed "s/^X//" >'README.bug' <<'END_OF_FILE'
XI think I found a bug in the g++ part of the gnu compiler.
XWe have Banyan Mail System and I hope everything gets to you. If not please let 
me know.
X
XI have included a short c++ listing which reproduces the bug,
Xthe assembler output and the output from the "-v" option given to the compiler.
XThe source isn't very useful because I have striped off all of the unnecessary 
Xsource code.  I wanted to reproduce the bug in a short example.
X
XThe command line I have used was:
X	c++ -o bar -v -g -O bar.c 2>verbose.out
X
XOptimization does not matter for the bug. The bug also appears if I don't use
Xthe -O option.
X
XWhen running this program I get the message:
X	Illegal instruction(coredump)
Xbut I extracted this example from a much bigger program and there I get a
Xmemory fault.
X
XI think "_vptr.foo" for the variable "t" in "func" isn't set correctly, but
Xafterwards it is needed to call "ins".
X
XNow to my environment:
XI have a COMPAQ Systempro with SCO UNIX 3.2 Version 4 with the Multiprocessor  
eXtension MPX 2.0.
XThe version of GCC is 2.3.3 and I didn't change anything at the source code.
XI gave i486-*-sco3.2v4 to the configure command.
X
XI hope I supplied you with all the information you need. If not feel free to 
contact me.
XMy mail address is:
X	Felix=Schmitt%TECHNIK%CE@bangate.compaq.com
X
XFelix

END_OF_FILE
echo shar: NEWLINE appended to \"'README.bug'\"
if test 1297 -ne `wc -c <'README.bug'`; then
    echo shar: \"'README.bug'\" unpacked with wrong size!
fi
# end of 'README.bug'
fi
if test -f 'bar.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bar.c'\"
else
echo shar: Extracting \"'bar.c'\" \(317 characters\)
sed "s/^X//" >'bar.c' <<'END_OF_FILE'
X
Xclass foo_base {
X};
X
Xclass foo : virtual public foo_base {
Xprivate:
X	int value;
Xpublic:
X	foo(int);
X	virtual void ins();
X	void Ins();
X};
X
Xinline void foo::Ins() { ins(); }
X
Xvoid foo::ins()
X{
X	value = 3;
X}
X
Xfoo::foo(int v) { value = v; }
X
X
Xvoid func (foo val)
X{
Xfoo t(val);
X	t.Ins();
X}
X
Xmain()
X{
Xfoo f(3);
X	func(f);
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'bar.c'\"
if test 318 -ne `wc -c <'bar.c'`; then
    echo shar: \"'bar.c'\" unpacked with wrong size!
fi
# end of 'bar.c'
fi
if test -f 'bar.s' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bar.s'\"
else
echo shar: Extracting \"'bar.s'\" \(3526 characters\)
sed "s/^X//" >'bar.s' <<'END_OF_FILE'
X	.file	"bar.c"
Xgcc2_compiled.:
X.text
X	.def	foo_base;	.scl	10;	.type	010;	.size	1;	
.endef
X	.def	.eos;	.val	1;	.scl	102;	.tag	foo_base;	
.size	1;	.endef
X	.def	foo_base;	.scl	13;	.tag	foo_base;	.size	
1;	.type	010;	.endef
X	.def	foo;	.scl	10;	.type	010;	.size	16;	.endef
X	.def	foo_base;	.val	0;	.scl	8;	.tag	
foo_base;	.size	1;	.type	010;	.endef
X	.def	_vb.foo_base;	.val	0;	.scl	8;	.tag	
foo_base;	.size	1;	.type	030;	.endef
X	.def	value;	.val	4;	.scl	8;	.type	04;	.endef
X	.def	_vptr.foo;	.val	8;	.scl	8;	.dim	2;	
.size	4;	.type	0330;	.endef
X	.def	.eos;	.val	16;	.scl	102;	.tag	foo;	.size	
16;	.endef
X	.align 4
X	.def	ins__3foo;	.val	ins__3foo;	.scl	2;	.type	
044;	.endef
X.globl ins__3foo
Xins__3foo:
X	pushl %ebp
X	movl %esp,%ebp
X	movl 8(%ebp),%eax
X	.def	.bf;	.val	.;	.scl	101;	.line	17;	.endef
X	.def	this;	.val	8;	.scl	9;	.tag	foo;	.size	
16;	.type	030;	.endef
X	.def	this;	.val	0;	.scl	4;	.tag	foo;	.size	
16;	.type	030;	.endef
X	.ln	2
X	movl $3,4(%eax)
X	.ln	3
X	leave
X	ret
X	.def	.ef;	.val	.;	.scl	101;	.line	3;	.endef
X	.def	ins__3foo;	.val	.;	.scl	-1;	.endef
X	.def	foo;	.scl	13;	.tag	foo;	.size	16;	.type	
010;	.endef
X	.align 4
X	.def	__3fooii;	.val	__3fooii;	.scl	2;	.tag	
foo;	.size	16;	.type	0150;	.endef
X.globl __3fooii
X__3fooii:
X	pushl %ebp
X	movl %esp,%ebp
X	movl 8(%ebp),%eax
X	cmpl $0,12(%ebp)
X	je .L6
X	movl %eax,%edx
X	addl $12,%edx
X	movl %edx,(%eax)
X.L6:
X	movl $_vt.foo,8(%eax)
X	.def	.bf;	.val	.;	.scl	101;	.line	21;	.endef
X	.def	this;	.val	8;	.scl	9;	.tag	foo;	.size	
16;	.type	030;	.endef
X	.def	__in.chrg;	.val	12;	.scl	9;	.type	04;	
.endef
X	.def	v;	.val	16;	.scl	9;	.type	04;	.endef
X	.def	this;	.val	0;	.scl	4;	.tag	foo;	.size	
16;	.type	030;	.endef
X	movl 16(%ebp),%edx
X	movl %edx,4(%eax)
X	leave
X	ret
X	.def	.ef;	.val	.;	.scl	101;	.line	1;	.endef
X	.def	__3fooii;	.val	.;	.scl	-1;	.endef
X	.def	foo;	.scl	13;	.tag	foo;	.size	16;	.type	
010;	.endef
X	.align 4
X	.def	func__FG3foo;	.val	func__FG3foo;	.scl	2;	.type	
044;	.endef
X.globl func__FG3foo
Xfunc__FG3foo:
X	pushl %ebp
X	movl %esp,%ebp
X	subl $16,%esp
X	.def	.bf;	.val	.;	.scl	101;	.line	25;	.endef
X	.def	val;	.val	8;	.scl	9;	.tag	foo;	.size	
16;	.type	010;	.endef
X	.ln	2
X	.def	.bb;	.val	.;	.scl	100;	.line	2;	.endef
X	.def	t;	.val	-16;	.scl	1;	.tag	foo;	.size	
16;	.type	010;	.endef
X	movl %ebp,%ecx
X	addl $-4,%ecx
X	movl %ecx,-16(%ebp)
X	movl 12(%ebp),%ecx
X	movl %ecx,-12(%ebp)
X	movb 20(%ebp),%cl
X	movb %cl,-4(%ebp)
X	.ln	3
X	.def	.bb;	.val	.;	.scl	100;	.line	3;	.endef
X	movl -8(%ebp),%edx
X	movswl 8(%edx),%eax
X	leal -16(%eax,%ebp),%eax
X	pushl %eax
X	movl 12(%edx),%eax
X	call *%eax
X	.def	.eb;	.val	.;	.scl	100;	.line	1;	.endef
X	.ln	3
X	.def	.eb;	.val	.;	.scl	100;	.line	3;	.endef
X	.ln	4
X	leave
X	ret
X	.def	.ef;	.val	.;	.scl	101;	.line	4;	.endef
X	.def	func__FG3foo;	.val	.;	.scl	-1;	.endef
X	.align 4
X	.def	main;	.val	main;	.scl	2;	.type	044;	.endef
X.globl main
Xmain:
X	pushl %ebp
X	movl %esp,%ebp
X	subl $16,%esp
X	.def	.bf;	.val	.;	.scl	101;	.line	31;	.endef
X	.ln	2
X	.def	.bb;	.val	.;	.scl	100;	.line	2;	.endef
X	.def	f;	.val	-16;	.scl	1;	.tag	foo;	.size	
16;	.type	010;	.endef
X	pushl $3
X	pushl $1
X	leal -16(%ebp),%eax
X	pushl %eax
X	call __3fooii
X	addl $12,%esp
X	.ln	3
X	addl $-16,%esp
X	movl -16(%ebp),%edx
X	movl %edx,(%esp)
X	movl -12(%ebp),%edx
X	movl %edx,4(%esp)
X	movl -8(%ebp),%edx
X	movl %edx,8(%esp)
X	movl -4(%ebp),%edx
X	movl %edx,12(%esp)
X	call func__FG3foo
X	.def	.eb;	.val	.;	.scl	100;	.line	3;	.endef
X	xorl %eax,%eax
X	.ln	4
X	leave
X	ret
X	.def	.ef;	.val	.;	.scl	101;	.line	4;	.endef
X	.def	main;	.val	.;	.scl	-1;	.endef
X.data
X	.align 4
X_vt.foo:
X	.value 0
X	.value 0
X	.long 1
X	.value 0
X	.value 0
X	.long ins__3foo

END_OF_FILE
echo shar: NEWLINE appended to \"'bar.s'\"
if test 3527 -ne `wc -c <'bar.s'`; then
    echo shar: \"'bar.s'\" unpacked with wrong size!
fi
# end of 'bar.s'
fi
if test -f 'verbose.out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'verbose.out'\"
else
echo shar: Extracting \"'verbose.out'\" \(1143 characters\)
sed "s/^X//" >'verbose.out' <<'END_OF_FILE'
XReading specs from /usr/local/lib/gcc-lib/i486-*-sco3.2v4/2.3.3/specs
Xgcc version 2.3.3
X /usr/local/lib/gcc-lib/i486-*-sco3.2v4/2.3.3/cpp -lang-c++ -v -undef 
-D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Di386 -Dunix -D__i386__ -D__unix__ 
-D__i386 -D__unix -D__OPTIMIZE__ -g -D_M_I386 -D_M_I86 -D_M_I86SM -D_M_SDATA 
-D_M_STEXT -D_M_UNIX -D_M_XENIX -D_M_SYS5 -D_M_SYSV -D_M_SYS3 -D_M_SYSIII 
-D_M_COFF -D_M_BITFIELDS -D_M_WORDSWAP -DM_I386 -DM_I86 -DM_I86SM -DM_SDATA 
-DM_STEXT -DM_UNIX -DM_XENIX -DM_SYS5 -DM_SYSV -DM_SYS3 -DM_SYSIII -DM_COFF 
-DM_BITFIELDS -DM_WORDSWAP bar.c /usr/tmp/cca11034.i
XGNU CPP version 2.3.3 (80386, ATT syntax)
X /usr/local/lib/gcc-lib/i486-*-sco3.2v4/2.3.3/cc1plus /usr/tmp/cca11034.i 
-quiet -dumpbase bar.cc -g -O -version -o /usr/tmp/cca11034.s
XGNU C++ version 2.3.3 (80386, ATT syntax) compiled by GNU C version 2.3.3.
X as -o /usr/tmp/cca110341.o /usr/tmp/cca11034.s
X ld -o bar /lib/crt1.o /usr/local/lib/gcc-lib/i486-*-sco3.2v4/2.3.3/crtbegin.o 
-L/usr/local/lib/gcc-lib/i486-*-sco3.2v4/2.3.3 -L/usr/local/lib 
/usr/tmp/cca110341.o -lg++ -lgcc -lc -lgcc 
/usr/local/lib/gcc-lib/i486-*-sco3.2v4/2.3.3/crtend.o /lib/crtn.o

END_OF_FILE
echo shar: NEWLINE appended to \"'verbose.out'\"
if test 1144 -ne `wc -c <'verbose.out'`; then
    echo shar: \"'verbose.out'\" unpacked with wrong size!
fi
# end of 'verbose.out'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0


Newsgroups: gnu.g++.bug