[llvm-bugs] [Bug 25876] New: -Wliteral-conversion warns about implicit conversion changing 0.99 to false

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 17 15:45:45 PST 2015


            Bug ID: 25876
           Summary: -Wliteral-conversion warns about implicit conversion
                    changing 0.99 to false
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gpakosz at pempek.net
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following program makes clang 3.7 emit a curious warning:
 ~ clang main.c                                                                
main.c:6:10: warning: implicit conversion from 'float' to 'bool' changes value
from 0.99 to false [-Wliteral-conversion]
  return 0.99f;
  ~~~~~~ ^~~~~
1 warning generated.


#include <stdio.h>
#include <stdbool.h>

bool f()
  return 1.99f;

int main(int argc, char* argv[])
  if (f())

  return 0;


 ~ clang --version                                                             
version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
 ~ 

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/20151217/781055f8/attachment.html>

More information about the llvm-bugs mailing list