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

            Bug ID: 45725
           Summary: Prebuilt Windows x64 binary allows conversion from
                    false to pointer
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++17
          Assignee: unassignedclangb...@nondot.org
          Reporter: ph...@seiryu.org
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

Created attachment 23416
  --> https://bugs.llvm.org/attachment.cgi?id=23416&action=edit
test code

Prebuilt clang for Windows x64 which can be downloaded from
https://llvm.org/builds/ compiles the test code with the following output. I
tried both 11.0.0(2663a25f) and 10.0.0.

============
>"\Program Files\LLVM\bin\clang.exe" -Wall -Wextra -std=c++17 -c test1.cpp
test.cpp:6:28: warning: initialization of pointer of type 'const char *' to
null
      from a constant boolean expression [-Wbool-conversion]
    [[maybe_unused]] s t = false;
                           ^~~~~
1 warning generated.
============

Expected result is error like below.

============
test.cpp:6:24: error: no viable conversion from 'bool' to 's'
    [[maybe_unused]] s t = false;
                       ^   ~~~~~
test.cpp:1:8: note: candidate constructor (the implicit copy constructor) not
      viable: no known conversion from 'bool' to 'const s &' for 1st argument
struct s {
       ^
test.cpp:1:8: note: candidate constructor (the implicit move constructor) not
      viable: no known conversion from 'bool' to 's &&' for 1st argument
struct s {
       ^
test.cpp:2:5: note: candidate constructor not viable: no known conversion from
      'bool' to 'const char *' for 1st argument
    s(const char *) {}
    ^
1 error generated.
============

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to