Bug 33955 - internal compiler error: in dependent_type_p, at cp/pt.c:15245 (vararg template problem)
Summary: internal compiler error: in dependent_type_p, at cp/pt.c:15245 (vararg templa...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: dgregor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-31 05:55 UTC by Eric Niebler
Modified: 2007-11-19 04:49 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-10-31 12:09:52


Attachments
preprocessed source code (93.18 KB, application/octet-stream)
2007-10-31 05:56 UTC, Eric Niebler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Niebler 2007-10-31 05:55:10 UTC
Compile the attached preprocessed file with "g++ -std=c++0x -c -x c++ bug.i". The compiler ICEs. Seems to be a problem with template varargs.

This is with the latest g++, built from svn on 10/30/2007, with some patches from Doug Gregor for various problems.
Comment 1 Eric Niebler 2007-10-31 05:56:31 UTC
Created attachment 14446 [details]
preprocessed source code
Comment 2 dgregor 2007-10-31 12:09:52 UTC
I can duplicate this locally. Here's a smaller test case:

template<typename T>
struct uncvref
{
  typedef T type;
};

template<typename... Args>
struct args
{
  static const int size = sizeof...(Args);
};

template<typename G, typename E, typename S, typename V, long GN = G::size, long EN = E::size>
struct apply_args;

template<typename... G, typename... E, typename S, typename V, long N>
struct apply_args<args<G...>, args<E...>, S, V, N, N>
{
  typedef args<
    typename G::template apply<typename uncvref<E>::type, S, V>::type...
    > type;
};

struct or_
{
  template<typename E, typename S, typename V>
  struct apply {
    typedef typename E::type type;
  };
};

template<typename T>
struct identity
{
  typedef T type;
};

apply_args<args<or_>, args<identity<int>>, float, double> a1;

I'm working on a fix now.
Comment 3 dgregor 2007-10-31 12:23:32 UTC
This tiny patch should fix the problem. We weren't digging into TYPENAME_TYPEs deep enough to find all of the parameter packs. The patch fixes both the original test case and the reduced one. However, I can't test it in isolation at the moment.

Index: pt.c
===================================================================
--- pt.c        (revision 129773)
+++ pt.c        (working copy)
@@ -2505,6 +2505,12 @@ find_parameter_packs_r (tree *tp, int *w
       *walk_subtrees = 0;
       return NULL_TREE;
        
+    case TYPENAME_TYPE:
+      cp_walk_tree (&TYPENAME_TYPE_FULLNAME (t), &find_parameter_packs_r,
+                   ppd, ppd->visited);
+      *walk_subtrees = 0;
+      return NULL_TREE;
+
     case TYPE_PACK_EXPANSION:
     case EXPR_PACK_EXPANSION:
       *walk_subtrees = 0;
Comment 4 dgregor 2007-11-02 03:26:58 UTC
Subject: Bug 33955

Author: dgregor
Date: Fri Nov  2 03:26:46 2007
New Revision: 129843

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129843
Log:
2007-11-01  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/33955
	* pt.c (find_parameter_packs_r): Handle TYPENAME_TYPE.

2007-11-01  Douglas Gregor  <doug.gregor@gmail.com>

	* g++.dg/cpp0x/pr33955.C: New.


	

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr33955.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 dgregor 2007-11-02 03:30:52 UTC
Fixed.