Description
Sorry if the title is not very clear. Basically if in my main.cc I'm importing a module, and that module exports a function which returns std::string, and I call that function from main.cc, it will fail to compile on latest clang with a linker error that
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.1/../../../../x86_64-linux-gnu/bin/ld: CMakeFiles/repro.dir/main.cc.o: in function `std::allocator_traits<std::allocator<char> >::deallocate(std::allocator<char>&, char*, unsigned long)':
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.1/../../../../include/c++/14.0.1/bits/alloc_traits.h:513: undefined reference to `std::allocator<char>::deallocate(char*, unsigned long)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
I tried to make a minimal reproducer but I'm not sure whether or not this is actually minimal, because I don't know if it could be reproduced without std::allocator or if it's specifically a problem with std::allocator. In module.cc you can change the return type of repro::repro to std::string
to see that it also happens with std::string
. It also happens with std::vector<char>
, and std::deque<char>
, and I guess any other standard container would have the same problem with an element type of char. I wasn't able to reproduce without using modules, which is why I labelled it as a modules problem.
Compiler Explorer reproducer for 19.0.0git: https://godbolt.org/z/5GbczMEa7
Compiler Explorer example of inability to reproduce for 18.1.0: https://godbolt.org/z/EEajTa1nj (same code as in above I just changed the compiler to x86-64 Clang 18.1.0)
As of writing this:
Problematic version of Clang tested on Compiler Explorer:
clang version 19.0.0git (https://github.com/llvm/llvm-project.git c43932e)
Problematic version of Clang that I originally found the problem on, from apt.llvm.org:
Debian clang version 19.0.0 (++20240327112225+c9d12664f2f9-1~exp1~20240327112239.613) c9d1266
Working version of Clang tested on Compiler Explorer:
clang version 18.1.0rc (https://github.com/llvm/llvm-project.git 461274b)