On Tue, Apr 8, 2008 at 2:32 PM, Pjotr Kourzanov
<[EMAIL PROTECTED]> wrote:
> Dear gcc developers,
>
> I have found a weird discrepancy in error/warning reporting in
> GCC4.x. The following fragment:
>
> enum e { A, B, C };
> struct u { enum e e:2; };
> void bar(struct u u) {
> switch (u.e) {
> case A:;
> }
> }
>
> It does (rightfully) trigger a -Wswitch warning on gcc-3.3 and
> gcc-3.4 but not on gcc-4.x.
>
> Note that the presence of the bitwidth specifier is essential for
> this bug. My estimate is that the specifier makes the field to lose
> its enum typedness, preventing further passes to from recognising
> this (rather important) error.
>
> This is a bit weird, since giving the specifier a value that does
> not match the range of the enum (e.g., :1) does trigger a warning
> (`e' is narrower than values of its type).
>
> I am using Debian-packaged compilers.
This is due to a fix that switch arguments need to be promoted properly.
The warning then likely fell through the cracks due to lack of a testcase
in the testsuite.
Please file a bugreport in bugzilla for this.
Thanks,
Richard.