Skip to content

Instantly share code, notes, and snippets.

@Atari2
Last active February 15, 2023 11:55
Show Gist options
  • Save Atari2/c76c71028a35b5e5a20de5446d99d28c to your computer and use it in GitHub Desktop.
Save Atari2/c76c71028a35b5e5a20de5446d99d28c to your computer and use it in GitHub Desktop.
msvc module bug undefined object

Steps to reproduce the bug:

  • First open a VS developer shell using Visual Studio Version 17.5.0 Preview 6.0
  • Compile first with cl /nologo /std:c++latest /EHsc main.cpp compilation should succeed.
  • Compile again with cl /nologo /std:c++latest /EHsc /DMODULES mod.ixx main.cpp you will now see an error like
C:\Users\anon\dev\TestInclude.h(13): error C2079: 'storage<Object>::value' uses undefined class 'Object'
main.cpp(8): note: see reference to class template instantiation 'storage<Object>' being compiled
#ifdef MODULES
import mod;
#else
template <typename T>
struct ptr { T* p; };
class obj : public ptr<class value> {};
class value { obj v; };
#endif
int main() {
obj o;
}
export module mod;
template <typename T>
struct ptr { T* p; };
export class obj : public ptr<class value> {};
export class value { obj v; };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment