<div dir="ltr"><div>I am trying to use Clang Modules, but getting the following error:</div><div><br></div><div>  error: definition with same mangled name as another definition</div><div><br></div><div>Full message:</div><div><br></div><div>In module 'foo1' imported from main.cpp:1:</div><div>In module 'format' imported from ./foo1.h:3:</div><div>./format.h:6:8: error: definition with same mangled name as another definition                                                                            void doFormat(T& out) {}</div><div>       ^</div><div>./format.h:6:8: note: previous definition is here</div><div><br></div><div>It seems like the error is happening when we pass lambda as templated argument (see below for minimized example). </div><div><br></div><div>Is this error expected? I am not sure how should I fix that as clang points to exactly the same place for previous definition.</div><div><br></div><div>Using clang built from latest trunk shows the same error, but also the following failed assertion:</div><div><br></div><div>llvm/lib/IR/Value.cpp:402: void llvm::Value::doRAUW(llvm::Value*, bool): Assertion `New->getType() == getType(</div><div>) && "replaceAllUses of value with new value of different type!"' failed.</div><div><br></div><div><br></div><div>Here is the following self-contained example:</div><div>Commandline:</div><div>clang++ --std=c++14 -I .  -fmodules -fcxx-modules -fmodules-cache-path=./modules_out/_module_cache -c main.cpp -o main.o</div><div><br></div><div>Files:</div><div>// --- main.cpp</div><div>#include "foo1.h"</div><div>#include "foo2.h"</div><div><br></div><div>int main () {</div><div>  return 0;</div><div>}</div><div><br></div><div>// -- foo1.h</div><div>#pragma once</div><div><br></div><div>#include "format.h"</div><div><br></div><div>void foo1() {</div><div>  format(0);</div><div>}</div><div><br></div><div>// -- foo2.h</div><div>#pragma once</div><div><br></div><div>#include "format.h"</div><div><br></div><div>void foo2() {</div><div>  format(0);</div><div>}</div><div><br></div><div>// -- format.h</div><div>#pragma once</div><div><br></div><div>class Formatter {</div><div>public:</div><div>  template <class T></div><div>  void doFormat(T& out) {}</div><div>};</div><div><br></div><div><br></div><div>template <class T></div><div>void format(T t) {</div><div>  Formatter f;</div><div>  auto lambda = [] {};</div><div>  f.doFormat(lambda);</div><div>}</div><div><br></div><div><br></div><div>// -- module.modulemap</div><div>module foo1 {</div><div>    header "foo1.h"</div><div>    export *</div><div>}</div><div><br></div><div>module foo2 {</div><div>    header "foo2.h"</div><div>    export *</div><div>}</div><div><br></div><div>module format {</div><div>    header "format.h"</div><div>    export *</div><div>}</div></div>