Bug 48768 - [4.6/4.7 Regression] ICE in get_expr_operands()
Summary: [4.6/4.7 Regression] ICE in get_expr_operands()
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-26 05:54 UTC by Arthur O'Dwyer
Modified: 2011-04-26 13:48 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.5, 4.5.1
Known to fail:
Last reconfirmed: 2011-04-26 08:35:09


Attachments
Output of "ajo-gcc -O1 -finline-small-functions test746970675.c -g -c -v" (858 bytes, text/plain)
2011-04-26 05:54 UTC, Arthur O'Dwyer
Details
gcc46-pr48768.patch (676 bytes, patch)
2011-04-26 09:01 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur O'Dwyer 2011-04-26 05:54:13 UTC
Created attachment 24098 [details]
Output of "ajo-gcc -O1 -finline-small-functions test746970675.c -g -c -v"

This reproduces for me with svn revision 172950 (2011-04-25), but it doesn't
reproduce with gcc-4.5.  I'm on Ubuntu 10.10, x86-64.  Attached "gcc-v.txt".

cat >test746970675.c <<EOF
extern int g_79, g_23;
int foo(int si1, int si2) {
    return (si1 > 0 && si1 > si2) || (si1 < 0 && si1 < si2) ? 0 : (si1 + 1);
}
int func_75() {
    int i, l_90 = 1;
    for (i = 0; i != 10; i = foo(i, 1)) {
  lbl_131:
        if (i) {
            int *l_126 = &l_90;
        } else if (l_90)
            goto lbl_131;
    }
    return 0;
}
unsigned func_58(int p_59) {
    return g_23;
}
int func_62() {
    unsigned char p_67;
    int i, p_63;
    if (func_58(func_75())) {
        return 0;
    } else {
        for (p_67 = 250; p_67 > 0; p_67 += 6) {
            for (i = 10; i >= 0; --i) {
                if (func_58(p_63) >= 0u) {
                    p_63 = func_75();
                    g_79 = (g_23 < 0) ? 0 : (g_23 - 1);
                }
            }
        }
    }
    return p_63;
}
EOF
gcc -O1 -finline-small-functions test746970675.c -g -c


unhandled expression in get_expr_operands():
 <error_mark 0x7ff771ced9f0>

test746970675.c: In function ‘func_62’:
test746970675.c:19:5: internal compiler error: in get_expr_operands, at tree-ssa-operands.c:1024


This test case is reduced from the output of Csmith
(http://embed.cs.utah.edu/csmith/), using the following command line:
csmith --bitfields --packed-struct -s 746970675 > test746970675.c
Comment 1 Jakub Jelinek 2011-04-26 08:35:09 UTC
Smaller testcase for -O -g:

int a, b;

int
bar (void)
{
  int i, j = 1;
  for (i = 0; i != 10; i++)
    {
    lab:
      if (i)
	{
	  int *k = &j;
	}
      else if (j)
	goto lab;
    }
  return 1;
}

inline int
foo (int x)
{
  unsigned int c = x;
  int d = x;
  if (bar ())
    for (; c; c++)
      while (x >= 0)
	if (foo (d) >= 0)
	  {
	    d = bar ();
	    a = b ? b : 1;
	  }
  return 0;
}

Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160124
Comment 2 Jakub Jelinek 2011-04-26 09:01:42 UTC
Created attachment 24100 [details]
gcc46-pr48768.patch

Untested fix.
Comment 3 Richard Biener 2011-04-26 11:35:01 UTC
Ugh.  Well, ok I suppose.
Comment 4 Jakub Jelinek 2011-04-26 13:35:24 UTC
Author: jakub
Date: Tue Apr 26 13:35:21 2011
New Revision: 172968

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172968
Log:
	PR debug/48768
	* tree-ssa.c (insert_debug_temp_for_var_def): If degenerate_phi_result
	is error_mark_node, set value to NULL.

	* gcc.dg/pr48768.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr48768.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa.c
Comment 5 Jakub Jelinek 2011-04-26 13:47:17 UTC
Author: jakub
Date: Tue Apr 26 13:47:13 2011
New Revision: 172970

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172970
Log:
	PR debug/48768
	* tree-ssa.c (insert_debug_temp_for_var_def): If degenerate_phi_result
	is error_mark_node, set value to NULL.

	* gcc.dg/pr48768.c: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/pr48768.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-ssa.c
Comment 6 Jakub Jelinek 2011-04-26 13:48:46 UTC
Fixed.