[llvm-bugs] [Bug 40137] New: False -Wunsequenced positive when combining comma and logical or
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Dec 22 03:15:16 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=40137
Bug ID: 40137
Summary: False -Wunsequenced positive when combining comma and
logical or
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: tony.wasserka at gmx.de
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Combining the comma operator with || seems to trigger false positives for
-Wunsequenced quite easily, see https://godbolt.org/z/azvBIZ for an example.
Both , and || should sequence their operands, so the warning is unjustified in
this case.
Example code:
int idx = 0;
bool result = ((idx++, false) || (idx++, false));
( NB: This problem in particular shows up when trying to use fold expressions
to emulate if-elseif cascades via short-circuiting of ||, e.g. "((idx++,
are_we_done_yet(idx)) || ...)". )
--
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/20181222/55574ea6/attachment.html>
More information about the llvm-bugs
mailing list