[LLVMbugs] [Bug 18585] New: No warning for implicit conversion from an integer expression with integer constants to char

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 22 13:19:30 PST 2014


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

            Bug ID: 18585
           Summary: No warning for implicit conversion from an integer
                    expression with integer constants to char
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            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 does not warn implicit conversions from integer expressions to smaller
types, such as char.

For the following example, Clang should warn the conversion from the expression
"c + 1" of integer type to "char", also for the "c += 1".

$: cat s.c 
static char a(char c) {
  c = c + 1;
  c += 1;
  return c;
}
$: clang-trunk -c -Wconversion s.c 
$: clang-trunk --version
clang version 3.5 (trunk 199549)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$: gcc-trunk -c -Wconversion s.c 
s.c: In function ‘a’:
s.c:2:9: warning: conversion to ‘char’ from ‘int’ may alter its value
[-Wconversion]
   c = c + 1;
         ^
s.c:3:5: warning: conversion to ‘char’ from ‘int’ may alter its value
[-Wconversion]
   c += 1;
     ^

-- 
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/20140122/1a85ae9b/attachment.html>


More information about the llvm-bugs mailing list