Bug 64970 - Hard error instead of SFINAE for expression in nested template alias
Summary: Hard error instead of SFINAE for expression in nested template alias
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.2
: P3 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2015-02-07 16:15 UTC by Eric Niebler
Modified: 2015-02-13 14:55 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.8.2, 4.9.1
Last reconfirmed: 2015-02-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Niebler 2015-02-07 16:15:23 UTC
The following code gives a hard error. I believe it should not.


template<typename T>
T && declval();

template<typename T>
struct void_ { using type = void; };

template<typename T>
using void_t = typename void_<T>::type;

template<class A, class B>
struct Outer
{
    template<class C, class D>
    using Inner = decltype(true ? declval<C>() : declval<D>());
};

template<class A, class B, typename Enable = void>
struct S
{};

template<class A, class B>
struct S<A, B, void_t<typename Outer<A, B>::template Inner<A, B>>>
{};

struct A{};
struct B{};
int main()
{
    S<A, B> s;
}


The error:

test.cpp: In substitution of ‘template<class A, class B> template<class C, class D> using Inner = decltype ((true ?  declval<C>() : declval<D>())) [with C = A; D = B; A = A; B = B]’:
test.cpp:32:13:   required from here
test.cpp:15:33: error: no match for ternary ‘operator?:’ (operand types are ‘bool’, ‘A’, and ‘B’)
     using Inner = decltype(true ? declval<C>() : declval<D>());
                                 ^
Comment 1 Ville Voutilainen 2015-02-08 22:05:31 UTC
Clang accepts the code without a hard error.
Comment 2 Paolo Carlini 2015-02-13 12:06:31 UTC
Mine.
Comment 3 paolo@gcc.gnu.org 2015-02-13 14:55:20 UTC
Author: paolo
Date: Fri Feb 13 14:54:48 2015
New Revision: 220684

URL: https://gcc.gnu.org/viewcvs?rev=220684&root=gcc&view=rev
Log:
/cp
2015-02-13  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/64970
	* decl.c (make_typename_type): Pass tsubst_flags_t argument
	to lookup_template_class.

/testsuite
2015-02-13  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/64970
	* g++.dg/cpp0x/sfinae55.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae55.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Paolo Carlini 2015-02-13 14:55:53 UTC
Fixed for 5.0.