Skip to content

Instantly share code, notes, and snippets.

@bryant
Created May 29, 2014 03:49
Show Gist options
  • Save bryant/6d68ef989885dadc7378 to your computer and use it in GitHub Desktop.
Save bryant/6d68ef989885dadc7378 to your computer and use it in GitHub Desktop.
clang-subst-fail
23:47:47 ~> cat subst-fail.cpp
#include <memory>
template <typename T, typename ...U> std::unique_ptr<T, U...> f() { return std::unique_ptr<T, U...>(); }
main() { f<int, std::default_delete<int>>(); }
23:47:52 ~> g++ -std=c++11 subst-fail.cpp
23:48:02 ~> clang++ -std=c++11 subst-fail.cpp
subst-fail.cpp:3:1: error: C++ requires a type specifier for all declarations
main() { f<int, std::default_delete<int>>(); }
^~~~
subst-fail.cpp:3:10: error: no matching function for call to 'f'
main() { f<int, std::default_delete<int>>(); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subst-fail.cpp:2:63: note: candidate template ignored: substitution failure [with T = int, U =
<std::default_delete<int>>]: too many template arguments for class template 'unique_ptr'
template <typename T, typename ...U> std::unique_ptr<T, U...> f() { return std::unique_ptr...
~~~ ^
2 errors generated.
23:48:06 ~> g++ --version
g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23:48:10 ~> clang++ --version
clang version 3.5.0 (git://github.com/llvm-mirror/clang d9ad71c332449fec52b2c7eb0755f7be50ef7cf6) (git://github.com/llvm-mirror/llvm 61e341e0bfcc83ec865fe763759e66ab3c2feba5)
Target: x86_64-unknown-linux-gnu
Thread model: posix
@bryant
Copy link
Author

bryant commented May 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment