[Bug c++/43646] New: decltype and std::integral_constant
jwakely dot gcc at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Apr 5 11:38:00 GMT 2010
This was originally sent as an email to gcc-bugs:
http://gcc.gnu.org/ml/gcc-bugs/2010-04/msg00167.html
I'm entering it here on his behalf...
The following translation unit seems to show a bug exhibited by 4.4.3 and 4.5.
#include <type_traits>
template<class X, class Y> struct plus
: std::integral_constant<
decltype(X::value + Y::value),
X::value + Y::value
> { };
int main(int argc, char* argv[]) {
return 0;
}
Compiling this file (test.cpp) with
g++ -std=c++0x -l stdc++ test.cpp
yields the following diagnostic:
test.cpp:7: error: 'decltype ((X::value + Y::value))'
is not a valid type for a template constant parameter
Am I missing something? The following works as intended:
#include <type_traits>
#include <utility>
template<class X, class Y> struct plus
: std::integral_constant<
typename std::identity<decltype(X::value + Y::value)>::type,
X::value + Y::value
> { };
int main(int argc, char* argv[]) {
return 0;
}
(i.e. just wrapping the use of decltype with std::identity)
--
Summary: decltype and std::integral_constant
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jwakely dot gcc at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43646
More information about the Gcc-bugs
mailing list