[LLVMbugs] [Bug 6919] New: clang++: inline friend operator< symbol emitted as non-inline causing linker errors
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Apr 24 08:27:40 PDT 2010
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: unassignedclangbugs at nondot.org
ReportedBy: edwintorok at gmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
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.
More information about the llvm-bugs
mailing list