[LLVMbugs] [Bug 18528] New: Flag -Wincompatible-pointer-types-discards-qualifiers does not warn conversion from const char* to char*

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jan 17 22:39:41 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18528

            Bug ID: 18528
           Summary: Flag  -Wincompatible-pointer-types-discards-qualifiers
                     does not warn conversion from const char* to char*
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang warns the small program "unwarned-const-qualifier-removal.c" that the
conversion from const char[5] to char* is not right. And it shows that the
warning is emitted by [-Wincompatible-pointer-types-discards-qualifiers].

However when I try "clang -Wincompatible-pointer-types-discards-qualifiers", no
warning is emitted. 

Please refer to the following instructions to reproduce the problem. 

$ clang-trunk -Wincompatible-pointer-types-discards-qualifiers
unwarned-const-qualifier-removal.c
$ clang-trunk -Weverything unwarned-const-qualifier-removal.c
unwarned-const-qualifier-removal.c:4:8: warning: initializing 'char *' with an
expression of type 'const char [5]' discards
      qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        char* s = "test";
              ^   ~~~~~~
1 warning generated.
$ cat unwarned-const-qualifier-removal.c
#include <stdio.h>

int main() {
        char* s = "test";
        s[0] = 'a';
        printf("%s\n", s);
        return 0;
}

$ clang-trunk --version
clang version 3.5 (trunk 198918)
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/20140118/0f574915/attachment.html>


More information about the llvm-bugs mailing list