[Bug c++/11548] New: [3.4 regression] Forwarding default template args ICEs
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Wed Jul 16 15:41:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11548
Summary: [3.4 regression] Forwarding default template args ICEs
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bangerth at dealii dot org
CC: gcc-bugs at gcc dot gnu dot org
This was recently broken:
---------------------------------
template <typename> struct length {
static const unsigned int value = 0;
};
template <typename T, int N = length<T>::value> class C;
template <typename T> class C<T, 0> {};
template <typename> C<int> foo ();
----------------------------------
Note that we need to look at the default argument of the general
template to realize that the value of N in C<int> equals zero, and
then take the partial specialization of C<T,0>. It's a funny idiom (used
in boost, for example), but it shouldn't ICE:
tmp/gg> ../build-gcc/gcc-install/bin/c++ -c x.cc
x.cc:8: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
A backtrace in the compiler is this:
#0 convert_nontype_argument (type=0x4001e57c, expr=0x40023348)
at ../../gcc/gcc/cp/pt.c:2999
#1 0x080734bb in convert_template_argument (parm=0x403d9ca8, arg=0x40023348,
args=0x40023330, complain=tf_error, i=1, in_decl=0x403d9f30)
at ../../gcc/gcc/cp/pt.c:3574
#2 0x08073619 in coerce_template_parms (parms=0x400232e8, args=0x2,
in_decl=0x403d9f30, complain=tf_error, require_all_arguments=1)
at ../../gcc/gcc/cp/pt.c:3676
#3 0x08074ad8 in lookup_template_class (d1=0x403dc118, arglist=0x403dc410,
in_decl=0x0, context=0x0, entering_scope=0, complain=tf_error)
at ../../gcc/gcc/cp/pt.c:4175
#4 0x080c3867 in finish_template_type (name=0x4001e57c, args=0x4001e57c,
entering_scope=1073866108) at ../../gcc/gcc/cp/semantics.c:2172
The crash is in the if()-clause of this snippet, since expr_type==0:
/* An integral constant-expression can include const variables or
enumerators. Simplify things by folding them to their values,
unless we're about to bind the declaration to a reference
parameter. */
if (INTEGRAL_TYPE_P (expr_type)
&& TREE_CODE (type) != REFERENCE_TYPE)
expr = decl_constant_value (expr);
None of the code in the lowest 3 frames seems to have been changed
recently, so I can't tell which the breaking patch is. Unfortunately,
I also can't see a work-around for the problem, short of actually
writing in the value of the default argument at the point of use :-(
W.
More information about the Gcc-bugs
mailing list