This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53162] New: unexpanded parameter packs not diagnosed in alias template used in default argument
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Apr 2012 00:50:10 +0000
- Subject: [Bug c++/53162] New: unexpanded parameter packs not diagnosed in alias template used in default argument
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53162
Bug #: 53162
Summary: unexpanded parameter packs not diagnosed in alias
template used in default argument
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: accepts-invalid, diagnostic
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
template<bool B>
struct bool_constant
{
static const bool value = B;
};
template<bool> struct enable_if { };
template<> struct enable_if<true> { typedef void type; };
template<typename... A>
struct F
{
template<typename... B>
using SameSize = bool_constant<sizeof...(A) == sizeof...(B)>;
template<typename... B,
typename = SameSize<B>>
F(int, B...) { }
template<typename... B,
typename = typename enable_if<SameSize<B>::value>::type>
F(char, B...) { }
};
int main()
{
F<int, int> f1(1, 2, 3);
F<int, int> f2('1', 2, 3);
}
$ g++ -std=c++11 t.cc
t.cc: In instantiation of âstruct F<int, int>â:
t.cc:27:17: required from here
t.cc:22:3: error: no type named âtypeâ in âstruct enable_if<false>â
F(char, B...) { }
^
The declaration of f1 should be rejected because the F(int, B...) constructor's
default template argument refers to the parameter pack B without expanding it,
but there is no error.
The declaration of f1 is rejected but with an unhelpful diagnostic, if the
problem was that there's no 'type' in enable_if then it should result in a
substitution failure not an error. The actual problem is that B is not expanded
in SameSize<B>, so the error should say so.