Open
Description
This is basically the same as #46961, which was fixed long ago. The only difference seems to be the function and DLL being referenced.
test.cpp:
int main() {
extern "C" __declspec(dllimport) int WSACleanup(void);
decltype(WSACleanup)* volatile ptr = &WSACleanup;
ptr();
}
Build:
- Compile:
cl -c test.cpp -guard:cf -nologo test.cpp
- Link:
<linker> test.obj -debug ws2_32.lib -guard:cf -delayload:ws2_32.dll dloadhelper.lib -nologo
With lld-link
, the resulting binary will hit a CFG failure. With link
, the binary will successfully run.
The results are the same whether cl
or clang-cl
is used as the compiler.
> lld-link --version
LLD 19.1.1