<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 - class static object member is initlized twice"
href="https://bugs.llvm.org/show_bug.cgi?id=50380">50380</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>class static object member is initlized twice
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>pangbw@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24862" name="attach_24862" title="tar file to reproduce the issue">attachment 24862</a> <a href="attachment.cgi?id=24862&action=edit" title="tar file to reproduce the issue">[details]</a></span>
tar file to reproduce the issue
steps to reproduce the issue:
$ tar xvf bug.zar
$/data/bpang/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang++ 2.cpp
3.cpp 4.cpp
/data/bpang/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang++ 2.cpp
3.cpp 4.cpp
/data/bpang/V_X_7/TCLLVM-280/vxsim_linux-lp64 $./a.out
./a.out
1
1
2
2
maxRect top -65536
/data/bpang/V_X_7/TCLLVM-280/vxsim_linux-lp64
$/data/bpang/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang++ 3.cpp
2.cpp 4.cpp
/data/bpang/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang++ 3.cpp
2.cpp 4.cpp
/data/bpang/V_X_7/TCLLVM-280/vxsim_linux-lp64 $./a.out
./a.out
2
2
1
1
maxRect top 65535
We can see depending on the order of 2.cpp and 3.cpp, the result is different.
And if compile/build these files with g++, we get a linking error:
/data/bpang/V_X_7/TCLLVM-280/vxsim_linux-lp64 $g++ 3.cpp 2.cpp 4.cpp
g++ 3.cpp 2.cpp 4.cpp
/tmp/ccUMUhCb.o:(.bss._ZN6_TRectIiE7maxRectE[_ZN6_TRectIiE7maxRectE]+0x0):
multiple definition of `_TRect<int>::maxRect'
/tmp/ccTplkLE.o:(.bss+0x10): first defined here
/tmp/ccUMUhCb.o:(.bss._ZN6_TRectIiE8nullRectE[_ZN6_TRectIiE8nullRectE]+0x0):
multiple definition of `_TRect<int>::nullRect'
/tmp/ccTplkLE.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
/data/bpang/V_X_7/TCLLVM-280/vxsim_linux-lp64 $g++ 2.cpp 3.cpp 4.cpp
g++ 2.cpp 3.cpp 4.cpp
/tmp/cc0QlF4s.o:(.bss+0x0): multiple definition of `_TRect<int>::nullRect'
/tmp/ccqmyACC.o:(.bss._ZN6_TRectIiE8nullRectE[_ZN6_TRectIiE8nullRectE]+0x0):
first defined here
/tmp/cc0QlF4s.o:(.bss+0x10): multiple definition of `_TRect<int>::maxRect'
/tmp/ccqmyACC.o:(.bss._ZN6_TRectIiE7maxRectE[_ZN6_TRectIiE7maxRectE]+0x0):
first defined here
collect2: error: ld returned 1 exit status</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>