[llvm-bugs] [Bug 40020] New: Illegitimate warning for -Wfloat-conversion

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 14 02:47:57 PST 2018


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

            Bug ID: 40020
           Summary: Illegitimate warning for -Wfloat-conversion
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: LTCMELO at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

When compiling  the C snippet below with -Wconversion, clangs throws the
warning -Wfloat-conversion for (i) expression `x = y', and (ii) for expression
`0 || y'. 

int f()
{
    int x;
    double y;
    x = y;
    0 || y;
    return 0;
}

My interpretation is that the warning for (ii) is not legitimate and should be
removed. As opposed to 6.3.1.4[floating point conversion], where truncation is
defined upon a conversion (e.g., as in an assignment), section 6.5.14 only
relates to the notion of comparison. In particular, it is relevant whether an
operand compare to 0 (the same of a integral of floating point), given the
logical OR only requires that its operands are of scalar type.

GCC 7.3 only produces the warning for case (i), which is according to my
expectation, as described above.

-- 
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/20181214/4791357f/attachment-0001.html>


More information about the llvm-bugs mailing list