<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 - Missing -Wgnu-folding-constant for initialisers"
href="https://bugs.llvm.org/show_bug.cgi?id=49581">49581</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missing -Wgnu-folding-constant for initialisers
</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>C
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>harald@gigawatt.nl
</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>clang has a -Wgnu-folding-constant warning for cases where the standard
requires a constant expression, the provided expression can be folded to a
constant, but this expression is not a constant according to the rules of the
standard. For instance, in C:
const int a = 1;
struct S { int b : a; };
results in
warning: expression is not an integer constant expression; folding it to a
constant is a GNU extension [-Wgnu-folding-constant]
struct S { int b : a; };
^
This warning is missing for initialisers:
const int a = 1;
const int b = a; // invalid but not diagnosed
As neither GCC nor clang currently diagnoses this (also , but other compilers
issue an error message, this makes it very easy to accidentally write
non-portable code that does not get noticed until a user uses one of those
other compilers.
P.S.: The C standard does not require a diagnostic for this, so this is not a
conformance issue.
P.P.S.: Although the warning for the first example talks about this as a GNU
extension, I cannot find any version of GCC that allows the first example here,
it seems to be only clang that allows this. It may be good to reword the
warning at the same time.</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>