This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH for c++/65556 (ICE with switch and bit-fields)
- From: James Greenhalgh <james dot greenhalgh at arm dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Marek Polacek <polacek at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, alan dot lawrence at arm dot com
- Date: Mon, 30 Mar 2015 15:00:54 +0100
- Subject: Re: C++ PATCH for c++/65556 (ICE with switch and bit-fields)
- Authentication-results: sourceware.org; auth=none
- References: <20150327143810 dot GC25731 at redhat dot com> <CAMe9rOogCeKbcfRW8xxewQiw5kEteOHgjpOEYk2NE2nXJenVHA at mail dot gmail dot com>
On Fri, Mar 27, 2015 at 11:14:31PM +0000, H.J. Lu wrote:
> On Fri, Mar 27, 2015 at 7:38 AM, Marek Polacek <polacek@redhat.com> wrote:
> > In this testcase we were crashing while trying to gimplify a switch, because
> > the types of the switch condition and case constants didn't match. This ICE
> > started with my -Wswitch-with-enum-bit-fields fix where I used the unlowered
> > type so that we're able to get hold of the enum type. The problem with that
> > is with ordinary bit-fields: we'll get the underlying type (e.g. long int),
> > but subsequent perform_integral_promotions promotes that to int, see
> > cp_perform_integral_promotions. Fixed by using the type of the condition in
> > case we're not dealing with an enum bit-field, i.e. do what we've been doing
> > before the -Wswitch fix, which ought to make this fix very safe.
> >
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> >
> > 2015-03-27 Marek Polacek <polacek@redhat.com>
> >
> > PR c++/65556
> > * semantics.c (finish_switch_cond): If the unlowered type is not an
> > enum, use the type of the condition.
> >
> > * c-c++-common/pr65556.c: New test.
> >
>
> The new test is failing for me on x86-32 and x32:
>
> https://gcc.gnu.org/ml/gcc-regression/2015-03/msg00392.html
Likewise on ARM. The testcase is fairly obviously not going to work
for any target with 32-bit long:
struct S
{
long l: 1;
long l2: 41;
unsigned long ul: 1;
unsigned long ul2: 41;
} s;
.../c-c++-common/pr65556.c:9:3: error: width of 'ul2' exceeds its type
Thanks,
James