Bug 52343 - [C++11] alias-definition dont work in `template<class>` params type
Summary: [C++11] alias-definition dont work in `template<class>` params type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Dodji Seketeli
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2012-02-22 18:42 UTC by trashyankes
Modified: 2013-01-07 10:44 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-02-23 00:00:00


Attachments
test file (509 bytes, text/x-c++src)
2012-11-06 20:53 UTC, Larry Evans
Details
compilation of test file with 2 compilers and 2 values of macro. (1.05 KB, text/plain)
2012-11-06 20:55 UTC, Larry Evans
Details

Note You need to log in before you can comment on or make changes to this bug.
Description trashyankes 2012-02-22 18:42:53 UTC
gcc version 4.7.0 20120203 (experimental) (niXman build)

code:
---------------------------
---------------------------

class bb {};
template<typename A>
using a1 = int; //same with char, bool and long
template<typename C>
using a2 = bb;
template<typename D>
using a3 = double;

template<template<class> class T>
struct aa
{

};

aa<a1> zz1; //error: integral expression 'a1' is not constant WTF??
aa<a2> zz2;
aa<a3> zz3;

---------------------------
---------------------------
Comment 1 Daniel Krügler 2012-02-22 22:31:40 UTC
Confirmed for 4.7.0 20120218 (experimental).

Reduced example:

//---
template<typename>
using A = int;

template<template<class> class>
struct B {};

B<A> b;
//---
Comment 2 Larry Evans 2012-11-06 20:53:02 UTC
Created attachment 28625 [details]
test file
Comment 3 Larry Evans 2012-11-06 20:55:19 UTC
Created attachment 28626 [details]
compilation of test file with 2 compilers and 2 values of macro.

The error is shown when -DUSE_ALIAS and with the later compiler, which
was created with release configuration.  The earlier compiler,
with debug configuration, doesn't show error.
Comment 4 dodji@seketeli.org 2012-12-22 16:08:25 UTC
A candidate patch for this was proposed at
http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01312.html.
Comment 5 Dodji Seketeli 2013-01-07 08:03:39 UTC
Author: dodji
Date: Mon Jan  7 08:03:33 2013
New Revision: 194960

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194960
Log:
PR c++/52343 - error with alias template as template template argument

In the example accompanying this patch, check_instantiated_arg tries
to ensure that a non-type template argument should be a constant if it
has integral or enumeration type.

The problem is that an alias template which type-id is, e.g, an
integer, looks like an argument that has integral/enumeration type:
its TREE_TYPE is an integer type.  So check_instantiated_arg
mistenkaly barks that this integral non-type argument is not a
constant.

Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.

gcc/cp/

	PR c++/52343
	* pt.c (check_instantiated_arg): Allow type template arguments.

gcc/testsuite/

	PR c++/52343
	* g++.dg/cpp0x/alias-decl-29.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Dodji Seketeli 2013-01-07 10:44:14 UTC
This should be fixed in trunk (4.8)