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

            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: unassignedclangb...@nondot.org
          Reporter: gpak...@pempek.net
                CC: llvm-bugs@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())
  {
    printf("yep!\n");
  }
  else
  {
    printf("nope!\n");
  }

  printf("\n¯\\_(ツ)_/¯\n");
  return 0;
}

---

 ~ clang --version                                                             
                                                                    clang
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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to