New issue
Advanced search Search tips

Issue 841122 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner: ----
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocked on:
issue 841908

Blocking:
issue 752720



Sign in to add a comment

dllimport functions don't work as template parameters

Project Member Reported by tzik@chromium.org, May 9 2018

Issue description

C++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>();
}
----
 

Comment 1 by tzik@chromium.org, May 9 2018

Blocking: 752720
Does cl.exe accept this?

Comment 3 by tzik@chromium.org, May 9 2018

Yes.

Comment 4 by tzik@chromium.org, 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.

Comment 5 by r...@chromium.org, 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.

Comment 6 by thakis@chromium.org, May 10 2018

Blockedon: 841908

Comment 7 by tzik@chromium.org, May 17 2018

Status: Fixed (was: ExternalDependency)

Sign in to add a comment