Message ID | alpine.LNX.2.00.1307121526140.4274@wotan.suse.de |
---|---|
State | New |
Headers | show |
On Fri, Jul 12, 2013 at 03:37:44PM +0200, Michael Matz wrote: > So, this is a dup of PR55771, I'm now proposing to add a test for > FLOAT_TYPE_P, not TYPE_UNSIGNED. Restarted the regstrap. Ok if it passes bootstrap/regtest. I'd say we should apply it to 4.8 too, while it might not be a regression (or at least not a recent one), it is a silent wrong-code issue. Sorry for forgetting about this PR. > PR middle-end/55771 > * convert.c (convert_to_real): Reject non-float inner types. > > testsuite/ > * c-c++-common/pr55771.c: New test. Jakub
Index: convert.c =================================================================== --- convert.c (revision 200240) +++ convert.c (working copy) @@ -213,10 +213,11 @@ convert_to_real (tree type, tree expr) switch (TREE_CODE (expr)) { /* Convert (float)-x into -(float)x. This is safe for - round-to-nearest rounding mode. */ + round-to-nearest rounding mode when the inner type is float. */ case ABS_EXPR: case NEGATE_EXPR: if (!flag_rounding_math + && FLOAT_TYPE_P (itype) && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (expr))) return build1 (TREE_CODE (expr), type, fold (convert_to_real (type, Index: testsuite/c-c++-common/pr55771.c =================================================================== --- testsuite/c-c++-common/pr55771.c (revision 0) +++ testsuite/c-c++-common/pr55771.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-do run } */ + +float global; +int main() +{ + unsigned long z = 1; + float x = -z; + global = x; + if (global < 0) + __builtin_abort (); + return 0; +}