<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 - -Wcomma flags Boost.Array code incorrectly"
href="https://bugs.llvm.org/show_bug.cgi?id=47566">47566</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-Wcomma flags Boost.Array code incorrectly
</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>All
</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>mclow.lists@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>The following file:
```
#include <boost/array.hpp>
int main () {
boost::array<int, 5> arr;
return arr.size();
}
```
when compiled with a recent clang using `-Wcomma` gives a warning.
/Users/marshall/Sources/Boost/main/boost/array.hpp:185:107: warning: possible
misuse of comma operator here [-Wcomma]
return i >= size() ? boost::throw_exception(std::out_of_range
("array<>: index out of range")), true : true;
^
/Users/marshall/Sources/Boost/main/boost/array.hpp:185:34: note: cast
expression to void to silence warning
return i >= size() ? boost::throw_exception(std::out_of_range
("array<>: index out of range")), true : true;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static_cast<void>(
)
The code that it is warning on is constexpr under C++11, and so must be a
single expression. It looks like this:
return i >= size()
? boost::throw_exception(...), true
: true;
The ", true" is necessary to make the two halves of the ?: expression have the
same type.
I believe that the code is correct, and the warning is erroneous. Certainly the
suggested "fix" is a complete non-starter.</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>