$: 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;
^
$
Extended Description
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; ^ $