User account creation filtered due to spam.

Bug 48617 - [C++0x] Problem with non-type template parameters and decltype
Summary: [C++0x] Problem with non-type template parameters and decltype
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
: 43646 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-04-15 09:03 UTC by Daniel Krügler
Modified: 2011-06-18 19:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-22 19:01:54


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2011-04-15 09:03:57 UTC
gcc 4.7.0 in C++0x mode rejects the following program:

//---------------
template<class T, decltype(T())> // #
struct A {};

A<int, 0> a;

int main() {}
//---------------

The error message annotated at line # is:

"error: 'decltype (T())' is not a valid type for a template constant parameter"

It seems to me that according to the FDIS this should be well-formed program: decltype is feasible as a /parameter-declaration/. The new type-equivalence rules in [temp.type] p. 2,

"If an expression e involves a template parameter, decltype(e) denotes a unique dependent type. Two such decltype-specifiers refer to the same type only if their expressions are equivalent (14.5.6.1)."

should allow for a compiler to deduce the meaning similar to other dependent contexts. See also [temp.dep.type] p. 8 for this matter:

"A type is dependent if it is [...] denoted by decltype(expression), where expression is type-dependent (14.6.2.2)."
Comment 1 Jason Merrill 2011-05-23 15:32:13 UTC
Author: jason
Date: Mon May 23 15:32:10 2011
New Revision: 174070

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174070
Log:
	PR c++/48617
	* pt.c (invalid_nontype_parm_type_p): Allow DECLTYPE_TYPE.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype27.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-05-25 01:08:10 UTC
Author: jason
Date: Wed May 25 01:08:07 2011
New Revision: 174158

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174158
Log:
	PR c++/48617
	* pt.c (invalid_nontype_parm_type_p): Allow DECLTYPE_TYPE.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/decltype27.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/pt.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-05-25 01:20:09 UTC
Fixed for 4.6.1.
Comment 4 Jason Merrill 2011-06-18 19:15:09 UTC
*** Bug 43646 has been marked as a duplicate of this bug. ***