Bug 11596 - [3.4 Regression] ICE with int templates
Summary: [3.4 Regression] ICE with int templates
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P1 critical
Target Milestone: 3.4.0
Assignee: Nathan Sidwell
URL:
Keywords: ice-on-valid-code
: 11548 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-07-19 22:01 UTC by Weiss
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-19 22:23:45


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Weiss 2003-07-19 22:01:52 UTC
The following example causes an ICE:


gonzo:~ # cat foo.cc
template <int A, int B, int C, bool D=(A<B)>
struct a
{
  enum { value = D? A+B: A+C };
};


template <int A>
struct b
{
//   enum { value = a<A,A,A>::value };  // compiles
//   enum { value = a<A,1,A>::value };  // compiles as well
//   enum { value = a<1,A,A>::value };  // compiles as well
  enum { value = a<1,1,A>::value };  // ICE
};


int main()
{
  return b<1>::value;
}

gonzo:~ # g++-cvs -v
Reading specs from /gml/shared/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ../gcc/configure --prefix=/gml/shared/gcc-cvs --enable-shared
--enable-languages=c,c++ --enable-threads=posix
Thread model: posix
gcc version 3.4 20030719 (experimental)

gonzo:~ # g++-cvs foo.cc
foo.cc:14: 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.
Comment 1 Andrew Pinski 2003-07-19 22:23:45 UTC
I can confirm this on the mainline (20030719).
From Phil's regression hunter: Search converges between 2003-07-08-trunk (#330) and 
2003-07-09-trunk (#331). 
Comment 2 janis187 2003-07-23 23:24:27 UTC
The regression in PR 11596 was introduced or exposed by a very large           
patch whose ChangeLog entries begin:

--- gcc/gcc/ChangeLog ---

2003-07-08  Mark Mitchell  <mark@codesourcery.com>

        * fold-const.c (make_range): Do not access operand 1 for a
        zero-operand operator.

--- gcc/gcc/cp/ChangeLog ---

2003-07-08  Mark Mitchell  <mark@codesourcery.com>

        * 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.

The regression hunt took place on i686-pc-linux-gnu and used the
submitter's test case.
Comment 3 GCC Commits 2003-07-25 10:16:22 UTC
Subject: Bug 11596

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	nathan@gcc.gnu.org	2003-07-25 10:16:13

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/ext: packed2.C 
Added files:
	gcc/testsuite/g++.dg/template: defarg3.C 

Log message:
	cp:
	PR c++/11596
	* pt.c (maybe_fold_nontype_arg, maybe_fold_nontype_args): Remove.
	(tsubst_template_arg): New.
	(tsubst_template_arg_vector): Rename to ...
	(tsubst_template_args): ... this. Accept a TREE_LIST form. Use
	tsubst_template_arg.
	(coerce_template_parms): Use tsubst_template_arg for default
	value.
	(tsubst_template_parms): Likewise.
	(tsubst_aggr_type): Adjust.
	(tsubst_decl): Likewise.
	(tsubst): Use tsubst_template_arg for a DOMAIN. Adjust.
	(tsubst_copy) <TEMPLATE_ID_EXPR case>: Use tsubst_template_args.
	testsuite:
	PR 11596
	* g++.dg/template/defarg3.C: New test.
	
	* g++.dg/ext/packed2.C: Pack member struct too. Explain why.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3552&r2=1.3553
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.734&r2=1.735
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2916&r2=1.2917
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/defarg3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/packed2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 4 Nathan Sidwell 2003-07-25 10:27:10 UTC
2003-07-25  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/11596
	* pt.c (maybe_fold_nontype_arg, maybe_fold_nontype_args): Remove.
	(tsubst_template_arg): New.
	(tsubst_template_arg_vector): Rename to ...
	(tsubst_template_args): ... this. Accept a TREE_LIST form. Use
	tsubst_template_arg.
	(coerce_template_parms): Use tsubst_template_arg for default
	value.
	(tsubst_template_parms): Likewise.
	(tsubst_aggr_type): Adjust.
	(tsubst_decl): Likewise.
	(tsubst): Use tsubst_template_arg for a DOMAIN. Adjust.
	(tsubst_copy) <TEMPLATE_ID_EXPR case>: Use tsubst_template_args.
Comment 5 Nathan Sidwell 2003-07-25 13:05:29 UTC
*** Bug 11548 has been marked as a duplicate of this bug. ***