clang-cl fails to compile dllexported class with std::vector of forward-declared nested type when using /std:c++20 compiler flag
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Hi,
The following program compiles successfully with the MSVC cl compiler, but fails to compile with clang-cl, even when the /clang:-fms-compatibility flag is specified.
`> clang-cl.exe -c test.cpp /std:c++20 /clang:-fms-compatibility `
```
#include
struct __declspec(dllexport) Foo {
class NestedFoo; // Forward declaration
std::vector v;
};
// Define the NestedFoo
struct __declspec(dllexport) Foo::NestedFoo {
int i ;
};
```
**Error:**
```
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.36.32532\include\vector(683,78): error: arithmetic on a pointer to an incomplete type 'value_type' (aka 'Foo::NestedFoo')
683 | const auto _Count = static_cast(_Right_data._Mylast - _Right_data._Myfirst);
|
```
```
> clang-cl.exe --version
clang version 21.1.1
Target: x86_64-pc-windows-msvc
Thread model: posix
```
Contributor guide
Assessment
This issue has not been assessed yet.