<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 - section type conflict with clang, not with gcc"
href="https://bugs.llvm.org/show_bug.cgi?id=48696">48696</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>section type conflict with clang, not with gcc
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>11.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>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>balazs.samu.fekete@ericsson.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=24365" name="attach_24365" title="code to reproduce.">attachment 24365</a> <a href="attachment.cgi?id=24365&action=edit" title="code to reproduce.">[details]</a></span>
code to reproduce.
We ran into an issue when adding a section attribute for certain symbols:
[[gnu::section(".bss")]] const int Stuff::xi = rand();
[[gnu::section(".bss")]] std::tr1::unordered_map<int,int> uom;
Full example code attached.
error I get when compiling:
$ clang++ -O2 -pipe -g -fno-omit-frame-pointer -std=c++11 main.cc stuff.cc
stuff.cc:8:59: error: 'uom' causes a section type conflict with 'xi'
[[gnu::section(".bss")]] std::tr1::unordered_map<int,int> uom;
^
stuff.cc:6:43: note: declared here
[[gnu::section(".bss")]] const int Stuff::xi = rand();
^
1 error generated.
Compiled without the section attributes result is that they are both put in
.bss, but when explicitly defining them, clang++ throws a section type
conflict.
Tried both with llvm 8.0 and 12.0. Also tried with
-fno-zero-initialized-in-bss, in that case they were put in .data, but I got
the same error when I added the attribute.
The same code compiles and runs with g++ (tried with versions 5.4.0 and 7.5.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>