[cfe-dev] [Clang Modules] error: definition with same mangled name as another definition

Bruno Cardoso Lopes via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 24 11:52:27 PDT 2017


Hi Dmitry,

On Sat, Jul 22, 2017 at 12:31 PM, Dmitry Panin via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> I am trying to use Clang Modules, but getting the following error:
>
>   error: definition with same mangled name as another definition
>
> Full message:
>
> In module 'foo1' imported from main.cpp:1:
> In module 'format' imported from ./foo1.h:3:
> ./format.h:6:8: error: definition with same mangled name as another
> definition
> void doFormat(T& out) {}
>        ^
> ./format.h:6:8: note: previous definition is here
>
> It seems like the error is happening when we pass lambda as templated
> argument (see below for minimized example).
>
> Is this error expected? I am not sure how should I fix that as clang points
> to exactly the same place for previous definition.

Looks like it should work, can you file a bug?

>
> Using clang built from latest trunk shows the same error, but also the
> following failed assertion:
>
> llvm/lib/IR/Value.cpp:402: void llvm::Value::doRAUW(llvm::Value*, bool):
> Assertion `New->getType() == getType(
> ) && "replaceAllUses of value with new value of different type!"' failed.
>
>
> Here is the following self-contained example:
> Commandline:
> clang++ --std=c++14 -I .  -fmodules -fcxx-modules
> -fmodules-cache-path=./modules_out/_module_cache -c main.cpp -o main.o
>
> Files:
> // --- main.cpp
> #include "foo1.h"
> #include "foo2.h"
>
> int main () {
>   return 0;
> }
>
> // -- foo1.h
> #pragma once
>
> #include "format.h"
>
> void foo1() {
>   format(0);
> }
>
> // -- foo2.h
> #pragma once
>
> #include "format.h"
>
> void foo2() {
>   format(0);
> }
>
> // -- format.h
> #pragma once
>
> class Formatter {
> public:
>   template <class T>
>   void doFormat(T& out) {}
> };
>
>
> template <class T>
> void format(T t) {
>   Formatter f;
>   auto lambda = [] {};
>   f.doFormat(lambda);
> }
>
>
> // -- module.modulemap
> module foo1 {
>     header "foo1.h"
>     export *
> }
>
> module foo2 {
>     header "foo2.h"
>     export *
> }
>
> module format {
>     header "format.h"
>     export *
> }
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc



More information about the cfe-dev mailing list