[LLVMbugs] [Bug 18914] New: No conversion warning on bitfields

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 20 15:39:45 PST 2014


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

            Bug ID: 18914
           Summary: No conversion warning on bitfields
           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

trunk 201801


$: cat s.c 
struct S {unsigned x:3;} s;
void f(unsigned sm) {
  s.x = sm;// no warning here.
  s.x = 9999111;
}

$: clang-trunk -Wconversion s.c -c
s.c:4:7: warning: implicit truncation from 'int' to bitfield changes value from
9999111 to 7
      [-Wbitfield-constant-conversion]
  s.x = 9999111;
      ^ ~~~~~~~
1 warning generated.

$: gcc-trunk -Wconversion s.c -c
s.c: In function ‘f’:
s.c:3:9: warning: conversion to ‘unsigned char:3’ from ‘unsigned int’ may alter
its value [-Wconversion]
   s.x = sm;// no warning here.
         ^
s.c:4:9: warning: large integer implicitly truncated to unsigned type
[-Woverflow]
   s.x = 9999111;
         ^
$

-- 
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/20140220/615d6854/attachment.html>


More information about the llvm-bugs mailing list