Skip to content

Duplicated warning message in -Wcomma #45783

@haoxintu

Description

@haoxintu
Bugzilla Link 46438
Version trunk
OS Linux
CC @zygoloid

Extended Description

This code, bug.cc, clang-9 to clang-trunk emit two duplicated warning message "warning: possible misuse of comma operator here [-Wcomma]", while clang-6 to clang-8 just give one warning message about this.

$cat bug.cc
const long var = 10;
static_assert (1 ? ( 0 , var ) : 0 , "" );

$clang++-trunk -Wcomma -c bug.cc
bug.cc:2:24: warning: possible misuse of comma operator here [-Wcomma]
static_assert (1 ? ( 0 , var ) : 0 , "" );
^
bug.cc:2:22: note: cast expression to void to silence warning
static_assert (1 ? ( 0 , var ) : 0 , "" );
^
static_cast( )
bug.cc:2:24: warning: possible misuse of comma operator here [-Wcomma]
static_assert (1 ? ( 0 , var ) : 0 , "" );
^
bug.cc:2:22: note: cast expression to void to silence warning
static_assert (1 ? ( 0 , var ) : 0 , "" );
^
static_cast( )
2 warnings generated.

$clang++-8 -Wcomma -c bug.cc
bug.cc:2:24: warning: possible misuse of comma operator here [-Wcomma]
static_assert (1 ? ( 0 , var ) : 0 , "" );
^
bug.cc:2:22: note: cast expression to void to silence warning
static_assert (1 ? ( 0 , var ) : 0 , "" );
^
static_cast( )
1 warning generated.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partygood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions