[llvm-bugs] [Bug 24564] New: Clang failed to discard const quilifier
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Aug 25 00:00:31 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24564
Bug ID: 24564
Summary: Clang failed to discard const quilifier
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: rajendra.sy at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Sample 'c' code:
#include <stdio.h>
int main()
{
const int k = 5;
int *kptr = &k;
*kptr = 7;
printf("%d\n", k);
return 0;
}
The output of program is '5' not '7'.
The clang shows a warning
test.c:6:9: warning: initializing 'int *' with an expression of type 'const int
*' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
int *kptr = &k;
As per the warning clang has to ignore the 'const' qualifier & update the value
to 7. But it does not update it.
I tried this with latest GCC it does throw a similar warning & update the value
to 7.
--
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/20150825/15345c05/attachment.html>
More information about the llvm-bugs
mailing list