http://llvm.org/bugs/show_bug.cgi?id=6919
Summary: clang++: inline friend operator< symbol emitted as
non-inline causing linker errors
Product: clang
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Blocks: 6916
Blender gives these linker errors:
../../lib/libbf_elbeem.a(elbeem.o): In function `operator<(ntlTriangle const&,
ntlTriangle const&)':
/home/edwin/clangtests/blender-2.49b/intern/elbeem/intern/elbeem.cpp:(.text+0x50):
multiple definition of `operator<(ntlTriangle const&, ntlTriangle const&)'
../../lib/libbf_elbeem.a(utilities.o):/home/edwin/clangtests/blender-2.49b/intern/elbeem/intern/utilities.cpp:(.text+0x2d50):
first defined here
$ cat >testcase.h <<EOF
class ntlTriangle
{
public:
inline friend bool operator<(const ntlTriangle &lhs, const ntlTriangle
&rhs);
};
bool operator<(const ntlTriangle &lhs,const ntlTriangle &rhs)
{
return true;
}
EOF
This header is included in 2 cpp files, so:
$ cp testcase.h t1.cpp
$ cp testcase.h t2.cpp
$ clang++ t1.cpp t2.cpp
/tmp/cc-BjvUfe.o: In function `operator<(ntlTriangle const&, ntlTriangle
const&)':
t2.cpp:(.text+0x0): multiple definition of `operator<(ntlTriangle const&,
ntlTriangle const&)'
/tmp/cc-c6oItc.o:t1.cpp:(.text+0x0): first defined here
GCC accepts this code and causes no linker errors.
As a workaround, if I add 'inline' to the definition then clang gets it right
too.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs