使用 MSVC 的模块中的访问冲突

Access violation in modules with MSVC

我非常渴望尝试 C++20 模块功能,但在运行时遇到了访问冲突。我能够将其简化为下面的最小示例。它适用于 clang,但会遇到 Microsoft 编译器所说的 av。这可能是这个实验性功能的编译器错误,但也许我只是用错了它们?
下面的命令行不会产生任何调试符号。我看了一下 Visual Studio 调试器出了什么问题:

Exception thrown at 0x00007FF7222E1027 in main.exe: 0xC0000005: Access violation reading location 0x000027AB00000021.

我在内存视图中检查了上述位置,它确实看起来像未映射的内存。

系统:Windows Server 2019,x64,版本 10.0.17763 Build 17763
CL 编译器:Visual Studio 2019,Microsoft (R) C/C++ 针对 x64 优化编译器版本 19.25.28612
Clang 编译器:clang 版本 10.0.0,目标:x86_64-pc-windows-msvc

fstmod.ixx:

export module fstmod;
export struct SampleFstMod {
  SampleFstMod(const char* pData) {}
};

sndmod.ixx:

export module sndmod;
import fstmod;
export struct SampleSndMod {
  SampleSndMod(SampleFstMod name = "SampleString") {}
};

main.cxx:

import sndmod;
int main(int, const char**) {
  SampleSndMod variable;
  return 0;
}

使用 clang 这个例子有效:

clang++ -fmodules-ts --precompile -x c++-module sndmod.ixx -o sndmod.pcm fstmod.pcm
clang++ -fmodules-ts --precompile -fprebuilt-module-path=. -x c++-module sndmod.ixx -o sndmod.pcm
clang++ -fmodules-ts --verbose -fprebuilt-module-path=. main.cxx -o main.exe
main.exe

使用 MSVC 进行翻译会在运行时产生访问冲突:

cl /EHsc /MDd /std:c++latest /experimental:module /c fstmod.ixx
cl /EHsc /MDd /std:c++latest /experimental:module /c sndmod.ixx
cl /EHsc /MDd /std:c++latest /experimental:module main.cxx fstmod.obj sndmod.obj
main.exe

编辑:
我在问:

注意,我检查了反汇编,它发生在调用后取消引用 eax 的值时,它正在评估 return 参数。

这并没有错,也没有UB。它应该可以正常编译而不会出现警告。
I communicated the issue with the Microsoft developers 这确实是一个编译器问题。根据他们的说法,它将在 16.7 Preview 1 中修复。