2.95.1 internal compiler error on template instantiation
Jonathan Thornburg
jthorn@galileo.thp.univie.ac.at
Mon Sep 13 09:29:00 GMT 1999
This is a bug report for gcc version 2.95.1 on sparc-sun-sunos4.1.3:
the input file given below produces an internal compiler error.
[I think this input is valid C++, but even if it isn't,
gcc should give an appropriate error message rather than
an internal compiler error.]
In detail, the error is this:
% /usr/local/bin/g++ --verbose
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.95.1/specs
gcc version 2.95.1 19990816 (release)
% /usr/local/bin/g++ -Wall -fsyntax-only tbug.cc
tbug.cc: In method `fp fd_grid::partial_x<X_axis>(int, int, int) const':
tbug.cc:110: instantiated from here
tbug.cc:83: Internal compiler error.
tbug.cc:83: Please submit a full bug report.
tbug.cc:83: See <URL: http://www.gnu.org/software/gcc/faq.html#bugreport > for instructions.
%
I built this gcc from the 2.95.1 distribution tarball after applying
two patches (provided by Craig Burley, and given below). Neither patch
modifies the compiler itself, only the TEXINPUTS environment variable
in gcc/f/Make-lang.in for TeXing the Fortran manual.
After applying these patches, I configured this gcc via
../src.gcc-2.95.1/configure --enable-shared --enable-haifa --with-cpu=v7 --enable-languages='c++,f77'
The input file `tbug.cc' is this:
#!/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-09-13 12:12 MET DST by <jthorn@galileo.thp.univie.ac.at>.
# Source directory was `/home/jonathan/mpe/cctry'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 3021 -rw-r--r-- tbug.cc
#
echo=echo
if mkdir _sh10989; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= tbug.cc ==============
if test -f 'tbug.cc' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'tbug.cc' '(file already exists)'
else
$echo 'x -' extracting 'tbug.cc' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'tbug.cc' &&
Xtypedef double fp;
X
Xclass grid
X {
Xpublic:
X int Nx() const { return Nx_; }
X int Ny() const { return Ny_; }
X int Nz() const { return Nz_; }
X
X fp dx() const { return dx_; }
X fp dy() const { return dy_; }
X fp dz() const { return dz_; }
X
X fp data(int i, int j, int k) const
X { return data_[i_stride_*i + j_stride_*j + k]; }
X fp &data(int i, int j, int k)
X { return data_[i_stride_*i + j_stride_*j + k]; }
X
X grid(int Nx_in, int Ny_in, int Nz_in,
X fp dx_in, fp dy_in, fp dz_in)
X : data_(new fp[Nx_in*Ny_in*Nz_in]),
X i_stride_(Ny_in*Nz_in), j_stride_(Nz_in),
X Nx_(Nx_in), Ny_(Ny_in), Nz_(Nz_in),
X dx_(dx_in), dy_(dy_in), dz_(dz_in)
X { }
X ~grid() { delete[] data_; }
Xprivate:
X fp *data_;
X int i_stride_, j_stride_;
X int Nx_, Ny_, Nz_;
X fp dx_, dy_, dz_;
X };
X
Xclass X_axis { };
Xclass Y_axis { };
Xclass Z_axis { };
X
Xtemplate <class axis> inline fp dxyz(const grid& g);
Xtemplate <> inline fp dxyz<X_axis>(const grid& g) { return g.dx(); }
Xtemplate <> inline fp dxyz<Y_axis>(const grid& g) { return g.dy(); }
Xtemplate <> inline fp dxyz<Z_axis>(const grid& g) { return g.dz(); }
X
Xtemplate <class axis> inline int i_plus_m(int i, int m) { return i; }
Xtemplate <class axis> inline int j_plus_m(int j, int m) { return j; }
Xtemplate <class axis> inline int k_plus_m(int k, int m) { return k; }
Xtemplate <> inline int i_plus_m<X_axis>(int i, int m) { return i+m; }
Xtemplate <> inline int j_plus_m<X_axis>(int j, int m) { return j+m; }
Xtemplate <> inline int k_plus_m<X_axis>(int k, int m) { return k+m; }
X
Xclass fd_grid
X : public grid
X {
Xprivate:
X fp fd_data(int i, int j, int k)
X { return data(i, j, k); }
X
X template <class axis,
X fp data_fn(const grid &g, int i, int j, int k)>
X fp data_at_m(int i, int j, int k, int m)
X const
X {
X return data_fn(*this,
X i_plus_m<axis>(i,m),
X j_plus_m<axis>(j,m),
X k_plus_m<axis>(k,m));
X }
X
X template <class axis,
X fp data_fn(const grid &g, int i, int j, int k)>
X fp partial_x__2targ(int i, int j, int k)
X const
X {
X const fp data_m1 = data_at_m<axis, data_fn>(i,j,k, -1);
X const fp data_p1 = data_at_m<axis, data_fn>(i,j,k, +1);
X return 0.5 * dxyz<axis>(*this) * (data_p1 - data_m1);
X }
X
Xpublic:
X template <class axis>
X fp partial_x(int i, int j, int k)
X const
X {
X return partial_x__2targ<axis, fd_data>(i, j, k);
X }
X
X template <class xaxis, class yaxis>
X fp partial_xy(int i, int j, int k)
X const
X {
X return partial_x__2targ<axis, partial_x<yaxis> >(i, j, k);
X }
X
X fd_grid(int Nx_in, int Ny_in, int Nz_in,
X fp dx_in, fp dy_in, fp dz_in)
X : grid(Nx_in, Ny_in, Nz_in,
X dx_in, dy_in, dz_in)
X { }
X ~fd_grid() { }
X };
X
X
Xvoid demo(class fd_grid &fdg)
X{
X for (int i = 0 ; i < fdg.Nx() ; ++i)
X {
X for (int j = 0 ; j < fdg.Ny() ; ++j)
X {
X for (int k = 0 ; k < fdg.Nz() ; ++k)
X {
X fp x_deriv = fdg.partial_x<X_axis>(i,j,k);
X fp y_deriv = fdg.partial_x<Y_axis>(i,j,k);
X fp z_deriv = fdg.partial_x<Z_axis>(i,j,k);
X fp xy_deriv = fdg.partial_xy<X_axis,Y_axis>(i,j,k)
X fdg.data(i,j,k) = z_deriv + x_deriv*y_deriv + xy_deriv;
X }
X }
X }
X}
SHAR_EOF
chmod 0644 'tbug.cc' ||
$echo 'restore of' 'tbug.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 'tbug.cc:' 'MD5 check failed'
c1760bc12212fcf8f7fb28398c02bc12 tbug.cc
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'tbug.cc'`"
test 3021 -eq "$shar_count" ||
$echo 'tbug.cc:' 'original size' '3021,' 'current size' "$shar_count!"
fi
fi
rm -fr _sh10989
exit 0
The patches I applied are:
#!/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-09-13 12:57 MET DST by <jthorn@galileo.thp.univie.ac.at>.
# Source directory was `/home/jonathan/news/gcc/patches'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 715 -rw-r--r-- g77.texi.patch
# 757 -rw-r--r-- g77.texi.patch2
#
echo=echo
if mkdir _sh11053; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= g77.texi.patch ==============
if test -f 'g77.texi.patch' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'g77.texi.patch' '(file already exists)'
else
$echo 'x -' extracting 'g77.texi.patch' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'g77.texi.patch' &&
X*** g77-e/gcc/f/Make-lang.in.~1~ Mon Jun 7 02:44:07 1999
X--- g77-e/gcc/f/Make-lang.in Fri Aug 27 08:52:08 1999
X*************** f/g77.dvi: $(srcdir)/f/g77.texi $(srcdir
X*** 246,252 ****
X # gcc/Makefile.in.
X if [ -f lang-f77 ]; then \
X! TEXINPUTS=$(srcdir)/f:$$TEXINPUTS tex $(srcdir)/f/g77.texi; \
X texindex g77.??; \
X! TEXINPUTS=$(srcdir)/f:$$TEXINPUTS tex $(srcdir)/f/g77.texi; \
X mv g77.dvi f; \
X else true; fi
X--- 246,252 ----
X # gcc/Makefile.in.
X if [ -f lang-f77 ]; then \
X! TEXINPUTS=${texidir}:$(srcdir):$$TEXINPUTS tex $(srcdir)/f/g77.texi; \
X texindex g77.??; \
X! TEXINPUTS=${texidir}:$(srcdir):$$TEXINPUTS tex $(srcdir)/f/g77.texi; \
X mv g77.dvi f; \
X else true; fi
SHAR_EOF
chmod 0644 'g77.texi.patch' ||
$echo 'restore of' 'g77.texi.patch' '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 'g77.texi.patch:' 'MD5 check failed'
5468a91743056ff3b342ecf17a3de973 g77.texi.patch
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'g77.texi.patch'`"
test 715 -eq "$shar_count" ||
$echo 'g77.texi.patch:' 'original size' '715,' 'current size' "$shar_count!"
fi
fi
# ============= g77.texi.patch2 ==============
if test -f 'g77.texi.patch2' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'g77.texi.patch2' '(file already exists)'
else
$echo 'x -' extracting 'g77.texi.patch2' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'g77.texi.patch2' &&
X*** g77-e/gcc/f/Make-lang.in.~1~ Fri Aug 27 08:52:08 1999
X--- g77-e/gcc/f/Make-lang.in Mon Aug 30 09:18:14 1999
X*************** f/g77.dvi: $(srcdir)/f/g77.texi $(srcdir
X*** 246,252 ****
X # gcc/Makefile.in.
X if [ -f lang-f77 ]; then \
X! TEXINPUTS=${texidir}:$(srcdir):$$TEXINPUTS tex $(srcdir)/f/g77.texi; \
X texindex g77.??; \
X! TEXINPUTS=${texidir}:$(srcdir):$$TEXINPUTS tex $(srcdir)/f/g77.texi; \
X mv g77.dvi f; \
X else true; fi
X--- 246,252 ----
X # gcc/Makefile.in.
X if [ -f lang-f77 ]; then \
X! TEXINPUTS=${texidir}:$(srcdir):$(srcdir)/f:$$TEXINPUTS tex $(srcdir)/f/g77.texi; \
X texindex g77.??; \
X! TEXINPUTS=${texidir}:$(srcdir):$(srcdir)/f:$$TEXINPUTS tex $(srcdir)/f/g77.texi; \
X mv g77.dvi f; \
X else true; fi
SHAR_EOF
chmod 0644 'g77.texi.patch2' ||
$echo 'restore of' 'g77.texi.patch2' '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 'g77.texi.patch2:' 'MD5 check failed'
006a5dc6074f92ce4be3bc82d846fdf9 g77.texi.patch2
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'g77.texi.patch2'`"
test 757 -eq "$shar_count" ||
$echo 'g77.texi.patch2:' 'original size' '757,' 'current size' "$shar_count!"
fi
fi
rm -fr _sh11053
exit 0
--
-- Jonathan Thornburg <jthorn@galileo.thp.univie.ac.at>
http://www.thp.univie.ac.at/~jthorn/home.html
Universitaet Wien (Vienna, Austria) / Institut fuer Theoretische Physik
"Every one we don't catch would be a "yet another major ms security hole",
and the theory tells us we can't catch all of them. So, we're just not
going to start down that path." --paulle@microsoft.com 1998 Bugtraq
More information about the Gcc-bugs
mailing list