Bug 57314 - [Core/1635] default template arguments for member template functions of class templates are instantiated before allowed
Summary: [Core/1635] default template arguments for member template functions of class...
Status: SUSPENDED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-17 15:10 UTC by Florian J. Weber
Modified: 2013-05-18 18:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-05-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian J. Weber 2013-05-17 15:10:03 UTC
GCC rejects the following code:

#include <type_traits>

template<bool bar> struct foo{
	template<typename T, typename = typename std::enable_if<bar>::type>
	void fun(T){}
};

int main(){
	foo<false> var{};
}

The error claims: “error: no type named 'type' in 'struct std::enable_if<false, void>”. Which is certainly true but according to my reading of the standard perfectly OK, because the default-arguments of templates must not be instantiated before usage:

Section 14.7.1:
“...The implicit instantiation of a class template specialization causes the implicit instantiation of the declarations, but not of the definitions or default arguments, of the class member functions, member classes, scoped member enumerations, static data members and member templates;...“
Comment 1 Daniel Krügler 2013-05-18 14:39:49 UTC
The standard does not clearly say that. Note that "default arguments" doesn't naturally extend to default *template* arguments. There exists a core language issue in regard to this kind of example,

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1635
Comment 2 Paolo Carlini 2013-05-18 18:26:10 UTC
Thanks Daniel. Let's suspend this for now.