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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Sumner, Brian via cfe-dev
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.

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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Clang Modules] error: definition with same mangled name as another definition

Sumner, Brian via cfe-dev
Hi Dmitry,

On Sat, Jul 22, 2017 at 12:31 PM, Dmitry Panin via cfe-dev
<[hidden email]> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



--
Bruno Cardoso Lopes
http://www.brunocardoso.cc
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Clang Modules] error: definition with same mangled name as another definition

Sumner, Brian via cfe-dev
Thanks for looking! 


On Mon, Jul 24, 2017 at 7:52 PM, Bruno Cardoso Lopes <[hidden email]> wrote:
Hi Dmitry,

On Sat, Jul 22, 2017 at 12:31 PM, Dmitry Panin via cfe-dev
<[hidden email]> 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
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>



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


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...