Commit 972afb58 by Jakub Jelinek Committed by Jakub Jelinek

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
parent 58ddc179
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> 2008-10-22 Richard Guenther <rguenther@suse.de>
* tree.def (COMPLEX_TYPE): Constrain element type. * 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) ...@@ -4503,7 +4503,12 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high)
{ {
if (TYPE_UNSIGNED (etype)) 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); exp = fold_convert (etype, exp);
} }
return fold_build2 (GT_EXPR, type, exp, return fold_build2 (GT_EXPR, type, exp,
......
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> 2008-10-22 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/30949 PR c/30949
......
/* 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment