Bug 43327 - [4.4/4.5 regression] ICE in unifiy.c
Summary: [4.4/4.5 regression] ICE in unifiy.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Dodji Seketeli
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-03-10 22:29 UTC by Roger Ferrer Ibanez
Modified: 2010-03-26 09:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.2.3 4.3.3 4.5.0
Last reconfirmed: 2010-03-16 09:14:54


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Ferrer Ibanez 2010-03-10 22:29:08 UTC
The following code

---
template <typename _T>
struct A
{
   template <int _N, int _M>
       struct B;

   template <int _N>
       struct B<_N, _T::m>
       {
           static void f();
       };
};

struct C
{
   static const int m = 4;
};


void m()
{
   A<C>::B<1, 4>::f();
}
-- 

causes the following ICE as of 4.2

[g++ 4.4]
test.cc: In function ‘void m()’:
test.cc:22: internal compiler error: in unify, at cp/pt.c:14081

g++ 4.1 yields this error, instead

[g++ 4.1]
test.cc: In function ‘void m()’:
test.cc:22: error: incomplete type ‘A<C>::B<1, 4>’ used in nested name specifier

This code seems fine to me (and so seems to intel, xlc++ and comeau online) so I assume it is some issue in g++.
Comment 1 Roger Ferrer Ibanez 2010-03-11 07:56:09 UTC
For what it's worth, replacing

 static const int m = 4;

with

 enum { m = 4 }; 

works fine.
Comment 2 Andrew Pinski 2010-03-13 00:59:53 UTC
Confirmed.
Comment 3 Dodji Seketeli 2010-03-17 14:55:49 UTC
A patch was proposed at http://gcc.gnu.org/ml/gcc-patches/2010-03/msg00662.html
Comment 4 Dodji Seketeli 2010-03-26 09:21:14 UTC
Subject: Bug 43327

Author: dodji
Date: Fri Mar 26 09:20:58 2010
New Revision: 157745

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157745
Log:
Fix for PR c++/43327

gcc/cp/ChangeLog:
	PR c++/43327
	* pt.c (add_to_template_args): Support NULL ARGS;
	(most_specialized_class): call coerce_template_parms on
	template arguments passed to get_class_bindings. Use
	add_to_template_args.
	(unify): Handle VAR_DECLs.

gcc/testsuite/ChangeLog:
	PR c++/43327
	* g++.dg/other/crash-10.C: New test.
	* g++.dg/other/crash-11.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/other/crash-10.C
    trunk/gcc/testsuite/g++.dg/other/crash-11.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Dodji Seketeli 2010-03-26 09:33:31 UTC
Fixed in 4.5.