https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64395
Bug ID: 64395 Summary: void_t doesn't work as expected Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: benzejaa at gmail dot com Hey all! I have what I *think* is a bug in gcc-4.9.2. I haven't tested it against the development version (mostly due to a lack of free time). I was messing around with "void_t concepts", and GCC didn't give me the expected behavior. I compared to clang, which did give me what I expected, so my assumption is that of a bug in GCC. This may be a duplicate under a different name (I find it hard to believe I was the first person to find the bug), but I couldn't find one. Here's my test code: #include<iostream> #include<utility> #include<type_traits> template< class... > using void_t = void; template< class, class = void > struct hasSize : std::false_type {}; template< class T > struct hasSize< T, void_t< decltype( std::declval<const T&>().size()) > > : std::true_type {}; int main() { std::cout << hasSize< std::string >::value << std::endl; std::cout << hasSize< char >::value << std::endl; return 0; } compiled as "g++ -std=c++11 main.cpp", I get the output: 1 1 and compiled as "clang++ -std=c++11 main.cpp", I get the output: 1 0 As one would expect the second value to be "false", this to me indicates a bug in g++. Cheers!