[llvm-bugs] [Bug 35429] New: Possibly a new diagnostic about strange ternary operator usage

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 27 01:07:29 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35429

            Bug ID: 35429
           Summary: Possibly a new diagnostic about strange ternary
                    operator usage
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

Given the code:

void test(double *CAM, double coeffs) {
   coeffs > 0.0 ? *CAM = 1.0 / coeffs : 0.0;
}

clang does not issue any warning.

The intended code is

void test(double *CAM, double coeffs) {
   *CAM = coeffs > 0.0 ? 1.0 / coeffs : 0.0;
}

Perhaps it would be possible to warn on that?

-- 
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/20171127/a13d7af2/attachment.html>


More information about the llvm-bugs mailing list