[llvm-bugs] [Bug 28776] New: Warn for implicit conversion from char literal to int

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 29 18:12:26 PDT 2016


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

            Bug ID: 28776
           Summary: Warn for implicit conversion from char literal to int
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david at doublewise.net
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

This is related to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55254&list_id=139817

I sometimes want to construct a string with n copies of a char c. However, I
frequently get the order of elements in the constructor mixed up. Rather than
saying std::string(80, '='), I accidentally call std::string('=', 80). If I go
through the trouble to put something in single quotes, I probably mean to pass
it to something expecting a char, not an integer.

Ultimately, I want to get a warning for this code:


#include <string>

int main() {
    std::string const probably_wrong('0', 80);
}

-- 
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/20160730/0fa7f761/attachment.html>


More information about the llvm-bugs mailing list