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: unassignedclangb...@nondot.org
          Reporter: tony.wasse...@gmx.de
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to