[llvm-bugs] [Bug 39375] New: False positive -Wcomma with static_cast<void> of dependent expression
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Oct 21 14:56:31 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39375
Bug ID: 39375
Summary: False positive -Wcomma with static_cast<void> of
dependent expression
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: oktal3700 at gmail.com
CC: llvm-bugs at lists.llvm.org
The following code generates one false positive of the -Wcomma warning
("possible misuse of the comma operator"). Tested with clang trunk via Matt
Godbolt's Compiler Explorer.
template <typename T>
void foo()
{
(void)42, 0; // ok
static_cast<void>(42), 0; // ok
(void)T{}, 0; // ok
static_cast<void>(T{}), 0; // false positive
}
The warning ignores comma expressions where the LHS is a CastExpr with a
CastKind of CK_ToVoid, but the expression static_cast<void>(T{}) has a CastKind
of CK_Dependent (confirmed with Compiler Explorer's AST view). This is a
surprising difference between the C-style cast to void and the equivalent
static_cast.
I came across this when trying to do the "expander trick" without a fold
expression or C-style cast, as in https://stackoverflow.com/a/30563282/1639256
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181021/2bcd35e9/attachment.html>
More information about the llvm-bugs
mailing list