re PR middle-end/37882 (Bitfield miscompilation)
PR middle-end/37882 * fold-const.c (build_range_type): For 1 .. signed_max range call build_nonstandard_inter_type if signed_type_for returned a type with bigger precision. * gcc.c-torture/execute/pr37882.c: New test. From-SVN: r141303
This commit is contained in:
parent
58ddc179d4
commit
972afb5819
|
@ -1,3 +1,10 @@
|
|||
2008-10-22 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/37882
|
||||
* fold-const.c (build_range_type): For 1 .. signed_max
|
||||
range call build_nonstandard_inter_type if signed_type_for
|
||||
returned a type with bigger precision.
|
||||
|
||||
2008-10-22 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
* tree.def (COMPLEX_TYPE): Constrain element type.
|
||||
|
|
|
@ -4503,7 +4503,12 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high)
|
|||
{
|
||||
if (TYPE_UNSIGNED (etype))
|
||||
{
|
||||
etype = signed_type_for (etype);
|
||||
tree signed_etype = signed_type_for (etype);
|
||||
if (TYPE_PRECISION (signed_etype) != TYPE_PRECISION (etype))
|
||||
etype
|
||||
= build_nonstandard_integer_type (TYPE_PRECISION (etype), 0);
|
||||
else
|
||||
etype = signed_etype;
|
||||
exp = fold_convert (etype, exp);
|
||||
}
|
||||
return fold_build2 (GT_EXPR, type, exp,
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2008-10-22 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/37882
|
||||
* gcc.c-torture/execute/pr37882.c: New test.
|
||||
|
||||
2008-10-22 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR c/30949
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/* PR middle-end/37882 */
|
||||
|
||||
struct S
|
||||
{
|
||||
int a : 21;
|
||||
unsigned char b : 3;
|
||||
} s;
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
s.b = 4;
|
||||
if (s.b > 0 && s.b < 4)
|
||||
__builtin_abort ();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue