<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - missed warning for ODR violation."
href="https://bugs.llvm.org/show_bug.cgi?id=35566">35566</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>missed warning for ODR violation.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pawel_sikora@zoho.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>% cat tu1.cpp
struct S { int i = 0; };
S foo() { return S(); }
% cat tu2.cpp
struct S { double i = 0.0; };
S bar() { return S(); }
% clang++ -Wodr -std=c++1y -fPIC -flto tu1.cpp tu2.cpp -c
% clang++ -Wodr -std=c++1y -fPIC -flto -shared tu1.o tu2.o -o tu.so
-fuse-ld=lld
<no warning>
from the other side, g++ 6.3.1 reports ODR violation.
% g++ -Wodr -std=c++1y -fPIC -flto tu1.cpp tu2.cpp -c
% g++ -Wodr -std=c++1y -fPIC -flto -shared tu1.o tu2.o -o tu.so -fuse-ld=gold
tu1.cpp:1:8: warning: type ‘struct S’ violates the C++ One Definition Rule
[-Wodr]
struct S { int i = 0; };
^
tu2.cpp:1:8: note: a different type is defined in another translation unit
struct S { double i = 0.0; };
^
tu1.cpp:1:20: note: the first difference of corresponding definitions is field
‘i’
struct S { int i = 0; };
^
tu2.cpp:1:23: note: a field of same name but different type is defined in
another translation unit
struct S { double i = 0.0; };
^
tu1.cpp:1:8: note: type ‘int’ should match type ‘double’
struct S { int i = 0; };
^</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>