https://bugs.llvm.org/show_bug.cgi?id=47566
Bug ID: 47566
Summary: -Wcomma flags Boost.Array code incorrectly
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
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.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs