Hello list,

The following code generates one false positive of the -Wcomma
warning: (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).

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

Thanks
Mat
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to