------- Comment #6 from tom at atoptech dot com 2009-03-10 20:34 ------- Subject: Re: cannot silence -Wconversion warnings for bit-fields
> AFAIK, that is not true. I just tried your very example with gcc 4.2.4 and it > doesn't warn with -Wall -Wextra -Wconversion. g++ did warn but not with -Wall, > you still needed to specify -Wconversion, and it did not warn in many cases. > So > please, check your facts. You are correct in 4.2 you still need the -Wconversion option. We upgraded from 3.4.6 to 4.2/4.3. In 3.4.6, gcc warned of this error without any additional options. > Fixing bugs alters behaviour. The change of behaviour was documented > beyond what is normally expected. You are splitting hairs. I don't see this change as a bug-fix. It's along the lines to reinterpreting the "C" or "C++" language with regard to bit-field assignments. The only way "C" or "C++" to assign a integral variable a bit field is an assignment: struct A { unsigned int v : 2; } void foo( A * a, int v ) { a->v = v; } For which "gcc" now issues an warning for, always! And there is no "language" defined way to eliminate this warning. Outside of writing something ugly like: struct A { union { unsigned int v : 2; unsigned int fill; }; }; void foo( A * a, int v ) { a->fill |= v & 0x3; } And if I have to write this, I might as well not use a bit-field! Again, gcc 4.3.x now issues thousands of warnings (in our code) for which we have NO reasonable and portable way to clean the code and NO way to suppress the warning. It makes the compiler (for us) not usable. > Of course it doesn't. Have you understood what -Wtraditional-converion (and > the > old -Wconversion) actually warned for? I don't care what "-Wconversion" previously did. We never used it, we did not need to! In 3.4.6 the compiler issued the implicit conversion warnings without additional options. In 4.2/4.3 you need -Wconversion to get these warnings. In 4.2.4, "gcc" doesn't warn about bit-fields, but in 4.3.x it does. > Really? Then I have no ideas. In any case, someone else would need to > take care of this because I do not have time. > > http://gcc.gnu.org/faq.html#support I don't understand why this change was made when "C" and the "C++" language has no support for it... Given this has not been been an issue with "C" for over 30 years, there is probably a reason it is not in the language. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39170