public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
@ 2013-08-21 10:15 doko at gcc dot gnu.org
  2013-08-21 10:26 ` [Bug tree-optimization/58209] " mpolacek at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: doko at gcc dot gnu.org @ 2013-08-21 10:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

            Bug ID: 58209
           Summary: ICE in extract_range_from_binary_expr, at
                    tree-vrp.c:2294
           Product: gcc
           Version: 4.7.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: doko at gcc dot gnu.org

seen with 4.6.4, 4.7.3, 4.8.1 and trunk with -O2, lowering to -O1 works around
the issue.

$ gcc-4.7 -c -O2 foo.c 
foo.c: In function 'pow2_s':
foo.c:3:7: internal compiler error: in build2_stat, at tree.c:3785
Please submit a full bug report,
with preprocessed source if appropriate.

$ /usr/lib/gcc-snapshot/bin/gcc -c -O2 foo.c 
foo.c: In function 'pow2_s':
foo.c:25:1: error: invalid (pointer) operands to plus/minus
 }
 ^
acc_tmp_14 = add_acc_5 + _1;
foo.c:25:1: internal compiler error: verify_gimple failed
Please submit a full bug report,


$ cat foo.c
#include <stdint.h>

void *pow2_s(void *arg)
{
    intptr_t n = (intptr_t)arg;

    if (n == 0)
        return (void *)1;

    n--;

    intptr_t s1 = (intptr_t)pow2_s((void *)n);
    intptr_t s2 = (intptr_t)pow2_s((void *)n);

    return (void *)(s1 + s2);
}

int main(void)
{
    intptr_t n = 5;

    pow2_s((void *)n);

    return 0;
}


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
@ 2013-08-21 10:26 ` mpolacek at gcc dot gnu.org
  2013-08-21 10:39 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-21 10:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-08-21
                 CC|                            |mpolacek at gcc dot gnu.org
          Component|c                           |tree-optimization
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
  2013-08-21 10:26 ` [Bug tree-optimization/58209] " mpolacek at gcc dot gnu.org
@ 2013-08-21 10:39 ` mpolacek at gcc dot gnu.org
  2013-08-21 10:50 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-21 10:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Reduced:

long *
foo (long n)
{
  if (n)
    return 0;
  long l = (long) foo (0);
  return (long *) (l + 1);
}


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
  2013-08-21 10:26 ` [Bug tree-optimization/58209] " mpolacek at gcc dot gnu.org
  2013-08-21 10:39 ` mpolacek at gcc dot gnu.org
@ 2013-08-21 10:50 ` mpolacek at gcc dot gnu.org
  2013-08-21 11:42 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-21 10:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Actually this one's better, the TC in #c2 ICEs only with trunk, the following
ICEs with 4.[678]/trunk:

long *
foo (long n)
{
  if (n)
    return (long *) 1;
  long s = (long) foo (1);
  return (long *) (s + 1);
}


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-08-21 10:50 ` mpolacek at gcc dot gnu.org
@ 2013-08-21 11:42 ` mpolacek at gcc dot gnu.org
  2013-08-21 12:06 ` [Bug tree-optimization/58209] [4.7/4.8/4.9 Regression] " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-21 11:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
And perhaps even better, use __INTPTR_TYPE__ instead of long...

typedef __INTPTR_TYPE__ T;
T *
foo (T n)
{
  if (n)
    return (T *) 1;
  T s = (T) foo (1);
  return (T *) (s + 1);
}


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] [4.7/4.8/4.9 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-08-21 11:42 ` mpolacek at gcc dot gnu.org
@ 2013-08-21 12:06 ` jakub at gcc dot gnu.org
  2013-08-22  9:27 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-21 12:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.7.4
            Summary|ICE in                      |[4.7/4.8/4.9 Regression]
                   |extract_range_from_binary_e |ICE in
                   |xpr, at tree-vrp.c:2294     |extract_range_from_binary_e
                   |                            |xpr, at tree-vrp.c:2294

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started in between r125500 and r126000, thus a regression.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] [4.7/4.8/4.9 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-08-21 12:06 ` [Bug tree-optimization/58209] [4.7/4.8/4.9 Regression] " jakub at gcc dot gnu.org
@ 2013-08-22  9:27 ` jakub at gcc dot gnu.org
  2013-08-23  7:47 ` [Bug tree-optimization/58209] [4.7 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-22  9:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 30684
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30684&action=edit
gcc49-pr58209.patch

Untested fix for this tail recursion bug.

For the release branches, I think better might be just to apply only the
testcase and find_tail_calls hunk with (m || a) instead of m in the added
condition.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] [4.7 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-08-22  9:27 ` jakub at gcc dot gnu.org
@ 2013-08-23  7:47 ` jakub at gcc dot gnu.org
  2014-05-07 16:01 ` jakub at gcc dot gnu.org
  2014-05-07 16:18 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-23  7:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.8.2, 4.9.0
            Summary|[4.7/4.8/4.9 Regression]    |[4.7 Regression] ICE in
                   |ICE in                      |extract_range_from_binary_e
                   |extract_range_from_binary_e |xpr, at tree-vrp.c:2294
                   |xpr, at tree-vrp.c:2294     |
      Known to fail|4.9.0                       |

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Aug 23 07:30:40 2013
New Revision: 201935

URL: http://gcc.gnu.org/viewcvs?rev=201935&root=gcc&view=rev
Log:
    PR tree-optimization/58209
    * tree-tailcall.c (process_assignment): Handle POINTER_PLUS_EXPR.
    (find_tail_calls): Give up for pointer result types if m is non-NULL.
    (adjust_return_value_with_ops): For PLUS_EXPR and pointer result type
    emit POINTER_PLUS_EXPR.
    (create_tailcall_accumulator): For pointer result type accumulate in
    sizetype type.

    * gcc.c-torture/execute/pr58209.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr58209.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-tailcall.c

Author: jakub
Date: Fri Aug 23 07:35:01 2013
New Revision: 201937

URL: http://gcc.gnu.org/viewcvs?rev=201937&root=gcc&view=rev
Log:
    PR tree-optimization/58209
    * tree-tailcall.c (find_tail_calls): Give up for pointer result types
    if m or a is non-NULL.

    * gcc.c-torture/execute/pr58209.c: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.c-torture/execute/pr58209.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-tailcall.c


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] [4.7 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-08-23  7:47 ` [Bug tree-optimization/58209] [4.7 " jakub at gcc dot gnu.org
@ 2014-05-07 16:01 ` jakub at gcc dot gnu.org
  2014-05-07 16:18 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-05-07 16:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Wed May  7 16:00:33 2014
New Revision: 210170

URL: http://gcc.gnu.org/viewcvs?rev=210170&root=gcc&view=rev
Log:
    Backported from mainline
    2013-08-23  Jakub Jelinek  <jakub@redhat.com>

    PR tree-optimization/58209
    * tree-tailcall.c (find_tail_calls): Give up for pointer result types
    if m or a is non-NULL.

    * gcc.c-torture/execute/pr58209.c: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/execute/pr58209.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-tailcall.c


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/58209] [4.7 Regression] ICE in extract_range_from_binary_expr, at tree-vrp.c:2294
  2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2014-05-07 16:01 ` jakub at gcc dot gnu.org
@ 2014-05-07 16:18 ` jakub at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-05-07 16:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58209

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |4.7.4
         Resolution|---                         |FIXED

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-05-07 16:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-21 10:15 [Bug c/58209] New: ICE in extract_range_from_binary_expr, at tree-vrp.c:2294 doko at gcc dot gnu.org
2013-08-21 10:26 ` [Bug tree-optimization/58209] " mpolacek at gcc dot gnu.org
2013-08-21 10:39 ` mpolacek at gcc dot gnu.org
2013-08-21 10:50 ` mpolacek at gcc dot gnu.org
2013-08-21 11:42 ` mpolacek at gcc dot gnu.org
2013-08-21 12:06 ` [Bug tree-optimization/58209] [4.7/4.8/4.9 Regression] " jakub at gcc dot gnu.org
2013-08-22  9:27 ` jakub at gcc dot gnu.org
2013-08-23  7:47 ` [Bug tree-optimization/58209] [4.7 " jakub at gcc dot gnu.org
2014-05-07 16:01 ` jakub at gcc dot gnu.org
2014-05-07 16:18 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).