r/cpp • • 18h ago

MSVC automatic import std::vector bug

https://developercommunity.visualstudio.com/t/MSVC-C20-modules-expose-std::vector-on/11135469?sort=newest&scope=follow
//math.ixx
module;
#include <vector>
export module math;
//nothing is exported

//main.cpp  Vs2026 18.9.2
import math;
int main()
{
std::vector<char> value = { 'a', 'b', 'c'}; // OK, but why?

return 0;
}
1 Upvotes

6 comments sorted by

4

u/manni66 10h ago
module;
//#include <vector>
export module math;
import std;

produces the expected error message: "error C2039: 'vector': is not a member of 'std'"

5

u/kamrann_ 9h ago

MSVC's modules implementation is broken on the "too permissive" side of things in numerous ways that probably tend to go unnoticed if it's your only compiler. Really fundamental stuff. It incorrectly allows use of names that are imported transitively without an intermediate "export import". It allows declarations from one module to be defined in an another. Every time I take code that I've been developing for a while on Windows and try to compile on Linux with clang, it invariably shows the code to have been totally broken.

4

u/fortsnek274 12h ago

Well, it'd probably get fixed. Unless it gets deprioritised.

6

u/ironykarl 11h ago

So, it'll either get fixed or it won't? 

2

u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB 14h ago