public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11548] New: [3.4 regression] Forwarding default template args ICEs
@ 2003-07-16 15:41 bangerth at dealii dot org
2003-07-16 16:01 ` [Bug c++/11548] " pinskia at physics dot uc dot edu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2003-07-16 15:41 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/11548] [3.4 regression] Forwarding default template args ICEs
2003-07-16 15:41 [Bug c++/11548] New: [3.4 regression] Forwarding default template args ICEs bangerth at dealii dot org
@ 2003-07-16 16:01 ` pinskia at physics dot uc dot edu
2003-07-25 12:54 ` nathan at gcc dot gnu dot org
2003-07-25 13:05 ` nathan at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-16 16:01 UTC (permalink / raw)
To: gcc-bugs
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
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-07-16 16:01:04
date| |
------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-16 16:01 -------
I can confirm this on the mainline (20030715).
Looks like an other fall out from Mark's patch on 2003-07-08
: Search converges between 2003-07-08-trunk (#330) and 2003-07-09-trunk (#331).
2003-07-08 Mark Mitchell
* cp-tree.def (NON_DEPENDENT_EXPR): New node.
* cp-tree.h (build_call_from_tree): Remove.
(build_member_call): Likewise.
(dependent_template_arg_p): Remove.
(any_dependent_template_arguments_p): New function.
(dependent_template_id_p): Likewise.
(any_type_dependent_arguments_p): Likewise.
(build_non_dependent_expr): Likewise.
(build_non_dependent_args): Likewise.
(build_x_compound_expr): Adjust prototype.
* call.c (build_new_method_call): Handle non-dependent expressions
correctly.
* decl2.c (grok_array_decl): Likewise.
(build_offset_ref_call_from_tree): Likewise.
(build_call_from_tree): Remove.
* error.c (dump_decl): Handle NON_DEPENDENT_EXPR.
(dump_expr): Likewise.
* init.c (build_member_call): Remove.
* mangle.c (write_expression): Update handling for template-ids.
* parser.c (cp_parser_primary_expression): Use
any_dependent_template_arguments_p. Update constant-expression
handling.
(cp_parser_postfix_expression): Use
any_type_dependent_arguments_p. Simplify call processing.
(cp_parser_unary_expression): Simplify.
(cp_parser_expression): Adjust for changes to
build_x_compound_expr.
(cp_parser_template_argument): Implement standard-conforming
parsing of non-type template arguments.
(cp_parser_direct_declarator): Use
cp_parser_fold_non_dependent_expr.
(cp_parser_fold_non_dependent_expr): New function.
(cp_parser_next_token_ends_template_argument_p): Likewise.
* pt.c (convert_template_argument): Do not call
maybe_fold_nontype_arg.
(tsubst_baselink): Likewise.
(tsubst_copy_and_build): Share common code. Make sizeof/alignof
processing work correctly for non-dependent expressions. Adjust
handling of COMPOUND_EXPR. Simplify call processing.
(value_dependent_expression_p): Deal with functional casts and
sizeof/alignof correctly.
(type_dependent_expression_p): Handle overloaded functions.
(any_type_dependent_arguments_p): New function.
(any_dependent_template_arguments_p): Likewise.
(dependent_template_p): Treat SCOPE_REFs as dependent.
(dependent_template_id_p): Simplify.
(build_non_dependent_expr): New function.
(build_non_dependent_args): Likewise.
* semantics.c (finish_stmt_expr): Don't make dependent
statement-expresions have void type.
(finish_call_expr): Handle non-dependent expressions
correctly.
* tree.c (lvalue_p_1): Treat NON_DEPENDENT_EXPRs as lvalues.
* typeck.c (cxx_sizeof_or_alignof_type): Give the expression
type size_t, even in templates.
(expr_sizeof): Likewise.
(finish_class_member_access_expr): Handle non-dependent expressions
correctly.
(build_x_indirect_ref): Likewise.
(build_x_binary_op): Likewise.
(build_x_unary_op): Likewise.
(build_x_conditional_expr): Likewise.
(build_x_compound_expr): Likewise.
* typeck2.c (build_x_arrow): Likewise.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/11548] [3.4 regression] Forwarding default template args ICEs
2003-07-16 15:41 [Bug c++/11548] New: [3.4 regression] Forwarding default template args ICEs bangerth at dealii dot org
2003-07-16 16:01 ` [Bug c++/11548] " pinskia at physics dot uc dot edu
@ 2003-07-25 12:54 ` nathan at gcc dot gnu dot org
2003-07-25 13:05 ` nathan at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-07-25 12:54 UTC (permalink / raw)
To: gcc-bugs
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
nathan at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |nathan at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/11548] [3.4 regression] Forwarding default template args ICEs
2003-07-16 15:41 [Bug c++/11548] New: [3.4 regression] Forwarding default template args ICEs bangerth at dealii dot org
2003-07-16 16:01 ` [Bug c++/11548] " pinskia at physics dot uc dot edu
2003-07-25 12:54 ` nathan at gcc dot gnu dot org
@ 2003-07-25 13:05 ` nathan at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-07-25 13:05 UTC (permalink / raw)
To: gcc-bugs
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
nathan at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |DUPLICATE
------- Additional Comments From nathan at gcc dot gnu dot org 2003-07-25 13:05 -------
*** This bug has been marked as a duplicate of 11596 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-07-25 13:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-16 15:41 [Bug c++/11548] New: [3.4 regression] Forwarding default template args ICEs bangerth at dealii dot org
2003-07-16 16:01 ` [Bug c++/11548] " pinskia at physics dot uc dot edu
2003-07-25 12:54 ` nathan at gcc dot gnu dot org
2003-07-25 13:05 ` nathan at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).