[LLVMbugs] [Bug 18624] New: Duplicate warnings on implicit bitfield constant conversion

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jan 26 22:37:45 PST 2014


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

            Bug ID: 18624
           Summary: Duplicate warnings on implicit bitfield constant
                    conversion
           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 emits two warnings for implicit constant truncation on bitfields. 
  1) one warning is from [-Wbitfield-constant-conversion]
  2) the other is from [-Wsign-conversion]


The second warning is wrong, as there is no signedness change in this
initialization (from long long to int). I have reported this bug in another
report (http://llvm.org/bugs/show_bug.cgi?id=18562). If this is fixed, the
second warning should be something similar to "implicit conversion loses
integer precision".

My point here in this bug report is that, provided that the second warning
message is right, then there will be two duplicate warnings on the same
conversion on bitfields, one is emitted by [-Wbitfield-constant-conversion],
and the other is by [-Wconversion].

The following describes the steps to reproduce the reported issue. 




$: cat no-conversion-warning-for-union.c
union U {
  signed int f:16;
};
static union U u = {0x84F9EDA7LL};
$: clang-trunk -c -Wconversion -std=c99 no-conversion-warning-for-union.c
no-conversion-warning-for-union.c:4:21: warning: implicit truncation from 'long
long' to bitfield changes value
      from 2230971815 to -4697 [-Wbitfield-constant-conversion]
static union U u = {0x84F9EDA7LL};
                    ^~~~~~~~~~~~
no-conversion-warning-for-union.c:4:21: warning: implicit conversion changes
signedness: 'long long' to 'int'
      [-Wsign-conversion]
static union U u = {0x84F9EDA7LL};
                   ~^~~~~~~~~~~~
2 warnings generated.
$: clang-trunk -v
clang version 3.5 (trunk 199927)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib64/gcc/x86_64-linux-gnu/4.4.6
Found candidate GCC installation: /usr/lib64/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib64/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib64/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib64/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib64/gcc/x86_64-linux-gnu/4.8.1
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0
Selected GCC installation: /usr/lib64/gcc/x86_64-linux-gnu/4.8

-- 
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/20140127/b90e5e77/attachment.html>


More information about the llvm-bugs mailing list