[llvm-bugs] [Bug 33924] New: Unexpected error "definition with same mangled name as another definition"
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jul 25 07:15:23 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33924
Bug ID: 33924
Summary: Unexpected error "definition with same mangled name as
another definition"
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Modules
Assignee: unassignedclangbugs at nondot.org
Reporter: pank.dm at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Created attachment 18843
--> https://bugs.llvm.org/attachment.cgi?id=18843&action=edit
Files that reproduce the error
It triggers on the following piece of code when we try to instantiate templated
function `format` in 2 separate modules:
// -- format.h
class Formatter {
public:
template <class T>
void doFormat(T& out) {}
};
template <class T>
void format(T t) {
Formatter f;
auto lambda = [] {};
f.doFormat(lambda);
}
(see full set of files in attachment)
Error 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
Seems like this is related to passing lambda from templated function. If I try
to call `doFormat` on regular class or move body of `format` into module `foo`
itself, then the error goes away.
Worth noting there is also assertion triggering when using clang built from
source in debug mode:
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.
Repro command line:
clang++ --std=c++14 -I . -fmodules -fcxx-modules
-fmodules-cache-path=./modules_out/_module_cache -c main.cpp -o main.o
A non-modular compilation that uses the same set of files finishes fine.
Let me know if you need any extra information.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170725/0a472390/attachment.html>
More information about the llvm-bugs
mailing list