On Mon, Aug 5, 2013 at 11:44 AM, Mike Stump <mikest...@comcast.net> wrote: > It is the intent for all_ones_mask_p to return true when 64 bits of ones in > an unsigned type of width 64 when size is 64, right? Currently the code uses > a signed type for tmask, which sets the upper bits to 1, when the value > includes the sign bit set and the equality code does check all 128 bits of > the the value for equality. This results in the current code returning false > in this case. The below change is the behavior change I'm talking about. > > We're fixing this in the wide-int branch, and just wanted to see if someone > wanted to argue this isn't a bug. > > If you want to see a small test case: > > typedef enum > { > DK_ERROR, > DK_SORRY, > DK_LAST_DIAGNOSTIC_KIND > } diagnostic_t; > > struct diagnostic_context > { > int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND]; > diagnostic_t *classify_diagnostic; > }; > > extern diagnostic_context *global_dc; > > bool > seen_error (void) > { > return (global_dc)->diagnostic_count[(int) (DK_ERROR)] || > (global_dc)->diagnostic_count[(int) (DK_SORRY)]; > }
These casts to int are relics of the old days when we used K&R C and the cast was recommended. I think that was a mistake, and we should remove the cast and use the enumerations directly as index. now, your issue may still stand with other test cases. -- Gaby