Issue |
125952
|
Summary |
On Windows, can't create constexpr assignment for function pointer of function marked with dllimport
|
Labels |
new issue
|
Assignees |
|
Reporter |
cgagnon-mw
|
I couldn't find this issue reported here, but if it's already been handled, feel free to archive this.
This code compiles on Mac and Linux (using the equivalent import/export annotations), but not on Windows:
```cpp
class __declspec(dllimport) MyClass {
public:
int* foo(int) const;
};
static constexpr auto(MyClass::*bar)(int) const = &MyClass::foo;
```
Here's the error output:
```txt
<source>:6:33: error: constexpr variable 'bar' must be initialized by a constant _expression_
static constexpr auto(MyClass::*bar)(int) const = &MyClass::foo;
^ ~~~~~~~~~~~~~
```
The program compiles on Windows if you replace `dllimport` with `dllexport`.
It also compiles if you simply remove `constexpr`. Using `constinit` gives essentially the same error.
Here's a similar issue report for MSVC (not authored by me).
https://developercommunity.visualstudio.com/t/cannot-constinitconstexpr-initialize-a/10456333
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs