From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 353 invoked by alias); 21 Jan 2004 17:59:28 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 310 invoked by alias); 21 Jan 2004 17:59:27 -0000 Date: Wed, 21 Jan 2004 17:59:00 -0000 Message-ID: <20040121175927.309.qmail@sources.redhat.com> From: "jsm at polyomino dot org dot uk" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20010621060602.3325.andreas.krakowczyk@fujitsu-siemens.com> References: <20010621060602.3325.andreas.krakowczyk@fujitsu-siemens.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/3325] cast of bit-field to same type gets discarded X-Bugzilla-Reason: CC X-SW-Source: 2004-01/txt/msg02631.txt.bz2 List-Id: ------- Additional Comments From jsm at polyomino dot org dot uk 2004-01-21 17:59 ------- Subject: Re: cast of bit-field to same type gets discarded On Wed, 21 Jan 2004, schwab at suse dot de wrote: > Can this be fixed in 3.4? I very much doubt a patch for it could fail to be too destabilising for a release branch; in any case, this isn't a regression. I attempted a resurrection of the patch and found it needed changes to expand_expr (though no experts thereon commented on the proper approach); I didn't get a patch to expand_expr as far as passing both bootstrap/regression tests and all of the tests below. I didn't get as far as looking at the debug info problems with the original patch (the ABI issues were, however, fixed, by using the declared type when layout was done and adjusting the type to the bit-field type later). Note: I don't suppose the original patch passed all the tests below either, given the need for middle-end support for the bit-field types. But presumably it didn't fail the existing regression tests which showed up the need for middle-end changes, and subsequent C front end changes may have caused this issue to show up now. Note: We should also look again at how bool bit-fields work in the light of the recent dicussion on the WG14 reflector, though I don't think that reached a clear consensus. /* Test that operations on bit-fields yield results reduced to bit-field type. */ /* Origin: Joseph Myers */ extern void exit (int); extern void abort (void); struct s { unsigned long long u33: 33; unsigned long long u40: 40; unsigned long long u41: 41; }; struct s a = { 0x100000, 0x100000, 0x100000 }; struct s b = { 0x100000000ULL, 0x100000000ULL, 0x100000000ULL }; struct s c = { 0x1FFFFFFFFULL, 0, 0 }; int main (void) { if (a.u33 * a.u33 != 0 || a.u33 * a.u40 != 0 || a.u40 * a.u33 != 0 || a.u40 * a.u40 != 0) abort (); if (a.u33 * a.u41 != 0x10000000000ULL || a.u40 * a.u41 != 0x10000000000ULL || a.u41 * a.u33 != 0x10000000000ULL || a.u41 * a.u40 != 0x10000000000ULL || a.u41 * a.u41 != 0x10000000000ULL) abort (); if (b.u33 + b.u33 != 0) abort (); if (b.u33 + b.u40 != 0x200000000ULL || b.u33 + b.u41 != 0x200000000ULL || b.u40 + b.u33 != 0x200000000ULL || b.u40 + b.u40 != 0x200000000ULL || b.u40 + b.u41 != 0x200000000ULL || b.u41 + b.u33 != 0x200000000ULL || b.u41 + b.u40 != 0x200000000ULL || b.u41 + b.u41 != 0x200000000ULL) abort (); if (a.u33 - b.u33 != 0x100100000ULL || a.u33 - b.u40 != 0xFF00100000ULL || a.u33 - b.u41 != 0x1FF00100000ULL || a.u40 - b.u33 != 0xFF00100000ULL || a.u40 - b.u40 != 0xFF00100000ULL || a.u40 - b.u41 != 0x1FF00100000ULL || a.u41 - b.u33 != 0x1FF00100000ULL || a.u41 - b.u40 != 0x1FF00100000ULL || a.u41 - b.u41 != 0x1FF00100000ULL) abort (); if (++c.u33 != 0 || --c.u40 != 0xFFFFFFFFFFULL || c.u41-- != 0) abort (); exit (0); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3325