<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 - -Wunused-const-variable inconsistent with constexpr"
href="https://bugs.llvm.org/show_bug.cgi?id=42630">42630</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-Wunused-const-variable inconsistent with constexpr
</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>Windows NT
</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>jvapen@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>When looking at the -Wunused-const-variable warning, we discovered that the
reporting of this warning is not consistent.
In the example below, we get a warning if:
- inline constexpr in unnamed namespace
- constexpr in unnamed namespace
- constexpr in global namespace
However, we don't get the warning for:
- inline constexpr in global namespace
=> From a programmers point of view, all 4 cases are the same -> constexpr
variable that ain't being used.
Example with warning:
<a href="https://godbolt.org/z/BWTmKA">https://godbolt.org/z/BWTmKA</a>
// Clang++ -std=c++17 -Werror -Wunused-const-variable
#include <type_traits>
namespace
{
// Dependent false_type
template<typename T>
struct dependent_false : std::false_type {};
template<typename T>
inline constexpr bool dependent_false_v = dependent_false<T>::value;
template<typename T>
auto func(T &&t) -> int
{
using TDeduce = std::decay_t<decltype(t)>;
if constexpr(true)
{
return 1;
}
else
{
static_assert(dependent_false_v<TDeduce>, "wrong types");
return 0;
}
}
}
int main()
{
return func(5);
}
=> Remove unnamed namespace to suppress the warning.</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>