<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 - Clang should give an error for .bss variables with invalid initializer"
href="https://bugs.llvm.org/show_bug.cgi?id=42813">42813</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang should give an error for .bss variables with invalid initializer
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>john.brawn@arm.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Currently if you compile a file containing this
int x __attribute__((section(".bss"))) = 1;
You get a fatal error in the backend
fatal error: error in backend: non-zero initializer found in section '.bss'
Or if the initializer is an address
int x = 1;
int *p __attribute__((section(".bss"))) = &x;
you get a slightly different error
fatal error: error in backend: cannot have fixups in virtual section!
We should be giving a proper error in the frontend, rather than failing with a
fatal error in the backend. gcc already does this, and gives the error
tmp.c:2:6: error: only zero initializers are allowed in section '.bss'
2 | int *p __attribute__((section(".bss"))) = &x;
| ^</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>