dllimport functions don't work as template parameters |
|||
Issue descriptionC++14 mode of clang-cl accepts functions with __declspec(dllimport) as template parametes, while C++17 mode of clang-cl doesn't. This is known issue for clang as https://bugs.llvm.org/show_bug.cgi?id=35772 for a while. This causes several compile failure when we build Chromium in C++17 mode, such as: - sk_free on SkFunctionWrapper parameter in https://skia.googlesource.com/skia.git/+/499a9b21087eaa52e53db565f32ff77494c0c3cc/include/private/SkTemplates.h - *_zero, *_init and *_cleanup on StackAllocated parameters in https://boringssl.googlesource.com/boringssl.git/+/8e75ae488047c519f14f2c08b02a55bf7712fa1d/include/openssl/digest.h and similar ones. - GetDeviceNamesWinXPImpl in https://chromium.googlesource.com/chromium/src/+/9d15c6b610c4f0b26829cb892e4d78b29c916218/media/audio/win/device_enumeration_win.cc We should fix either clang-cl or sources, but I'm not sure which we should go. Here is as an example for foo.cc below. $ clang-cl /std:c++17 /c foo.cc hoge.cc(8,3): error: no matching function for call to 'f' f<&g>(); ^~~~~ hoge.cc(3,6): note: candidate template ignored: invalid explicitly-specified argument for 1st template parameter void f() {} ^ 1 error generated. ---- foo.cc template <void(*)()> void f() {} __declspec(dllimport) void g(); void h() { f<&g>(); } ----
,
May 9 2018
Does cl.exe accept this?
,
May 9 2018
Yes.
,
May 9 2018
This is due to the spec change around template parameters. http://en.cppreference.com/w/cpp/language/template_parameters#Template_non-type_arguments C++14 doesn't require the function parameters to be constexpr, while C++17 does require that. The function pointer taken from a imported function is not constexpr on clang-cl in both C++14 and C++17.
,
May 9 2018
There is a patch out, it's just stalled: https://reviews.llvm.org/D43320 If somebody wants to grab it, that's OK with me.
,
May 10 2018
,
May 17 2018
|
|||
►
Sign in to add a comment |
|||
Comment 1 by tzik@chromium.org
, May 9 2018