http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54101
Bug #: 54101 Summary: Using std::declval for types without a default constructor and with a deleted copy constructor errors. Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: supercilious.d...@gmail.com GCC rejects code which using std::declval on some types. From what I can understand from the C++11 standard, such uses of declval are legal inside decltype. Clang accepts this without error. GCC 4.7.1 (and the current 4.8 from the master branch of the git repository today) Example: #include <utility> class NonCopyable { public: // Not default constructable. NonCopyable ( int ) { } NonCopyable ( NonCopyable const& ) = delete; }; int main ( void ) { std::common_type<NonCopyable, NonCopyable>::type t(0); } fails with: In file included from /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/bits/move.h:57:0, from /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/bits/stl_pair.h:61, from /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/utility:72, from gccbug.cxx:1: /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/type_traits: In instantiation of 'struct std::common_type<NonCopyable, NonCopyable>': gccbug.cxx:16:45: required from here /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/type_traits:1786:29: error: use of deleted function 'NonCopyable::NonCopyable(const NonCopyable&)' { typedef decltype(true ? declval<_Tp>() : declval<_Up>()) type; }; ^ gccbug.cxx:10:5: error: declared here NonCopyable ( NonCopyable const& ) = delete; ^ In file included from /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/bits/move.h:57:0, from /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/bits/stl_pair.h:61, from /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/utility:72, from gccbug.cxx:1: /home/user/install/VA-HEPHAESTUS/include/c++/4.8.0/type_traits:1786:29: error: use of deleted function 'NonCopyable::NonCopyable(const NonCopyable&)' { typedef decltype(true ? declval<_Tp>() : declval<_Up>()) type; }; ^ gccbug.cxx:10:5: error: declared here NonCopyable ( NonCopyable const& ) = delete; ^