This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Wrong g++ output (egcs-1.1.[12])
- To: jakob at ostenfeld dot dk
- Subject: Re: Wrong g++ output (egcs-1.1.[12])
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sat, 27 Mar 1999 22:08:41 +0100
- Cc: egcs-bugs at cygnus dot com
- References: <19990326111259.B29296@ostenfeld.dk> <199903262051.VAA00707@mira.isdn.cs.tu-berlin.de> <19990327141035.A3728@ostenfeld.dk> <199903271353.OAA07146@mira.isdn.cs.tu-berlin.de> <19990327194419.C4115@ostenfeld.dk>
> The compiler doesn't complain. But when I look at the assembly output,
> I can see that it calls the wrong destructors.
Thanks again for your report. Based on your information, I have
reproduced the problem in the example below. When compiled with
egcs-2.91.60 on i586-pc-linux-gnu, this code prints
Foo::Foo
This is wrong, it should call 'Bar::Bar'. With the development
snapshot, it works correctly.
The problem is that egcs makes the constructors of the anonymous
unions weak, so during linking, the right copy is eliminated. I
believe this was fixed with
1998-08-20 Jason Merrill <jason@yorick.cygnus.com>
(grokfndecl): Likewise. Members of anonymous types have no linkage.
In this specific example, a different fix would be to use 'the typedef
name for linkage purposes'. Then, the constructors do not need to be
duplicated in different translation units.
Jakob, as a work-around, you should give the types explicit names,
like
typedef struct D { int foobar; } D;
This will avoid the problem.
Hope this helps,
Martin
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1999-03-27 21:57 CET by <martin@mira>.
# Source directory was `/home/martin/tmp'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 64 -rw-rw-r-- makefile
# 59 -rw-rw-r-- x1.cc
# 216 -rw-rw-r-- x2.cc
# 57 -rw-rw-r-- x1.h
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
if test "$gettext_dir" = FAILED && test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
set `$dir/gettext --version 2>&1`
if test "$3" = GNU
then
gettext_dir=$dir
fi
fi
if test "$locale_dir" = FAILED && test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
echo=echo
else
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo
$echo 'WARNING: not restoring timestamps. Consider getting and'
$echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh13179; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= makefile ==============
if test -f 'makefile' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'makefile' '(file already exists)'
else
$echo 'x -' extracting 'makefile' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'makefile' &&
x: x1.o x2.o
X $(CXX) -o x x2.o x1.o
X
x1.o: x1.cc
X
x2.o: x2.cc
X
SHAR_EOF
$shar_touch -am 0327215699 'makefile' &&
chmod 0664 'makefile' ||
$echo 'restore of' 'makefile' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'makefile:' 'MD5 check failed'
63f9a79edce8440937f027111815b9c4 makefile
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'makefile'`"
test 64 -eq "$shar_count" ||
$echo 'makefile:' 'original size' '64,' 'current size' "$shar_count!"
fi
fi
# ============= x1.cc ==============
if test -f 'x1.cc' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'x1.cc' '(file already exists)'
else
$echo 'x -' extracting 'x1.cc' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'x1.cc' &&
struct {int i;}a1;
struct {int i;}a2;
#include "x1.h"
C c;
SHAR_EOF
$shar_touch -am 0327214399 'x1.cc' &&
chmod 0664 'x1.cc' ||
$echo 'restore of' 'x1.cc' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'x1.cc:' 'MD5 check failed'
a93697abe4d2f1b8f8023db03216b7f3 x1.cc
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'x1.cc'`"
test 59 -eq "$shar_count" ||
$echo 'x1.cc:' 'original size' '59,' 'current size' "$shar_count!"
fi
fi
# ============= x2.cc ==============
if test -f 'x2.cc' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'x2.cc' '(file already exists)'
else
$echo 'x -' extracting 'x2.cc' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'x2.cc' &&
#include <stdio.h>
struct Foo{
X Foo();
};
typedef struct { Foo foobar; } D;
X
#include "x1.h"
X
Foo::Foo()
{
X printf("Foo::Foo\n");
}
X
Bar::Bar()
{
X printf("Bar::Bar\n");
}
X
int dummy()
{
X C c;
X D d;
}
X
main()
{
}
SHAR_EOF
$shar_touch -am 0327214599 'x2.cc' &&
chmod 0664 'x2.cc' ||
$echo 'restore of' 'x2.cc' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'x2.cc:' 'MD5 check failed'
37241ef96583e32827a9c319a2777f7d x2.cc
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'x2.cc'`"
test 216 -eq "$shar_count" ||
$echo 'x2.cc:' 'original size' '216,' 'current size' "$shar_count!"
fi
fi
# ============= x1.h ==============
if test -f 'x1.h' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'x1.h' '(file already exists)'
else
$echo 'x -' extracting 'x1.h' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'x1.h' &&
struct Bar{
X Bar();
};
typedef struct { Bar foobar; } C;
SHAR_EOF
$shar_touch -am 0327213299 'x1.h' &&
chmod 0664 'x1.h' ||
$echo 'restore of' 'x1.h' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'x1.h:' 'MD5 check failed'
725d4891c164c66b18aebab0d0e8d570 x1.h
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'x1.h'`"
test 57 -eq "$shar_count" ||
$echo 'x1.h:' 'original size' '57,' 'current size' "$shar_count!"
fi
fi
rm -fr _sh13179
exit 0