Issue 125521
Summary [clang++] Implicit template instantiations in modules cause errors in other modules
Labels clang
Assignees
Reporter BernardoGomesNegri
    If module A instantiates a template Class\<T\>, any module that imports module A and also tries to instantiate Class\<T\> (with the same T) will get an error:
```
/home/modBug/reproducer/src/hello.h:8:38: error: declaration 'get' attached to named module 'Mod2' can't be attached to other modules
 8 |     template <typename V> friend int get() noexcept;
      | ^
/home/modBug/reproducer/src/hello.h:3:27: note: also found
    3 | template <typename V> int get() noexcept {return 0;};
 |                           ^
```
See [this reproducer](https://github.com/user-attachments/files/18644458/reproducer.zip) or https://godbolt.org/z/d7YW7TM4a where instantiating List\<int\> in Mod2 causes any module that also imports Mod2 to fail to instantiate List\<int\>.
I think this is a bug because the global module fragment is not supposed to be exported.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to