Bug 24820 - [3.4/4.0/4.1 regression] SEGV in integer_valued_real_p at gcc/builtins.c:6711
Summary: [3.4/4.0/4.1 regression] SEGV in integer_valued_real_p at gcc/builtins.c:6711
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.0.3
Assignee: Andrew Pinski
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2005-11-12 16:18 UTC by Serge Belyshev
Modified: 2005-11-13 06:24 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-*-*, i?86-*-*
Build:
Known to work: 3.3.3
Known to fail:
Last reconfirmed: 2005-11-12 16:36:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serge Belyshev 2005-11-12 16:18:39 UTC
// Compile this with -O2 -ffast-math to get segfault

double floor (double);
double bar (double sum)
{
  int i;
  for (i = 0; i < 256; i++)
    sum += floor (0.5 + (i - 128));
  return sum;
}
Comment 1 Laurent GUERBY 2005-11-12 16:36:26 UTC
confirmed on x86_64-linux gcc version 4.1.0 20051111 (experimental)

z.c: In function 'bar':
z.c:3: internal compiler error: tree check: expected class 'expression', have 'constant' (real_cst) in integer_valued_real_p, at builtins.c:6710
Comment 2 Andrew Pinski 2005-11-12 16:58:36 UTC
integer_valued_real_p is missing a break or something.  Looking more into it.
Comment 3 Andrew Pinski 2005-11-12 17:03:21 UTC
This is a latent bug from 2003 (3.4 time frame):
* builtins.c (integer_valued_real_p): New function to test if
	a floating point expression has an integer valued result.
	(fold_trunc_transparent_mathfn): Optimize foo(foo(x)) as
	foo(x) where foo is an integer rounding function.  Similarly,
	optimize foo(bar(x)) as bar(x), and foo((double)(int)x) as
	(double)(int)x when both foo and bar are integer rounding
	functions and we don't need to honor errno.
	(fold_builtin_trunc, fold_builtin_floor, fold_builtin_ceil):
	New functions to fold trunc, floor and ceil.
	(fold_builtin): Use fold_builtin_trunc to fold BUILT_IN_TRUNC*,
	fold_builtin_floor to fold BUILT_IN_FLOOR* and fold_builtin_ceil
	to fold BUILT_IN_CEIL*.
Comment 4 Andrew Pinski 2005-11-12 18:27:29 UTC
I will take care of this one, it is a simple matter of a break missing.
Comment 5 Andrew Pinski 2005-11-13 06:18:52 UTC
Subject: Bug 24820

Author: pinskia
Date: Sun Nov 13 06:18:48 2005
New Revision: 106851

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106851
Log:
2005-11-13  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24820
        * testsuite/gcc.dg/pr24820.c: New test.
2005-11-13  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24820
        * builtins.c (integer_valued_real_p): Add break in
        REAL_CST having TREE_OVERFLOW set.


Added:
    trunk/gcc/testsuite/gcc.dg/pr24820.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Andrew Pinski 2005-11-13 06:24:52 UTC
Fixed for 4.0.3.
Comment 7 Andrew Pinski 2005-11-13 06:25:02 UTC
Subject: Bug 24820

Author: pinskia
Date: Sun Nov 13 06:24:59 2005
New Revision: 106852

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106852
Log:
2005-11-13  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24820
        * testsuite/gcc.dg/pr24820.c: New test.
2005-11-13  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/24820
        * builtins.c (integer_valued_real_p): Add break in
        REAL_CST having TREE_OVERFLOW set.


Added:
    branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/pr24820.c
      - copied unchanged from r106851, trunk/gcc/testsuite/gcc.dg/pr24820.c
Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/builtins.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog