Bug 25328 - [4.0 regression] ICE in get_indirect_ref_operands, at tree-ssa-operands.c:1453
Summary: [4.0 regression] ICE in get_indirect_ref_operands, at tree-ssa-operands.c:1453
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: objc (show other bugs)
Version: 4.0.3
: P1 major
Target Milestone: 4.0.3
Assignee: Jakub Jelinek
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2005-12-09 16:30 UTC by Debian GCC Maintainers
Modified: 2005-12-22 23:10 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.0.1 4.1.0 4.2.0
Known to fail: 4.0.3
Last reconfirmed: 2005-12-22 13:03:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2005-12-09 16:30:52 UTC
[forwarded from http://bugs.debian.org/342662]

seen with 4.0 20051201, 4.1 20051205, works with 4.0.2 20050808

$ cat test.m
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv)
{
        int status = 0;
        char msg[100] = "";

        if(!status && !strcmp(msg, "")) {
                status = 200;
                snprintf(msg, 100, "OK");
        }
        exit(0);
}
mosca@retirante:~/devel/inova/v3-cgid$ gcc -c -O1 test.m
test.m: In function 'main':
test.m:7: internal compiler error: in get_indirect_ref_operands, at
tree-ssa-operands.c:1453
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 1 Andrew Pinski 2005-12-09 17:00:12 UTC
Hmm, the main diff is:
-            msg.24 = &msg;
-            D.3575 = *msg.24;
-            iftmp.23 = (int) D.3575;
+            msg.24 = (const unsigned char * {ref-all}) &msg;
+            D.3522 = *msg.24;
+            iftmp.23 = (int) D.3522;


Someone is not folding something correctly:
D.3575_10 = *&msgD.3533


Reducing (this is not fully an objc issue, I don't know why it is only reproducible with the objc front-end though).
Comment 2 Andrew Pinski 2005-12-09 17:16:30 UTC
Reduced testcase:
int main(int argc, char **argv)
{
        int status = 0;
        char msg[100] = "";
        if(__builtin_strcmp(msg, ""))
                status = 200;
}

There a couple of issue here, first DCE is not removing some code even though it is dead code but that is not the real issue.  The real issue is that DOM is ICEing, it is not folding *&a to a or a[0] since a is an array.
Comment 3 Mark Mitchell 2005-12-19 19:24:03 UTC
ICE on very plausible code: P1.
Comment 4 Jeffrey A. Law 2005-12-20 21:33:37 UTC
I've been unable to reproduce this with the gcc-4.1 branch sources.  IT's going to be awful difficult to fix if I can't reproduce the problem.

At the very least I'll need the before-dom dumps and some analysis of whatever
transformation is causing the problem.

Note that a failure to fold is more likely a symptom of a problem elsewhere,
like mucked up types and such -- which may also explain why this has been reported as front-end specific.

Jeff
Comment 5 Jeffrey A. Law 2005-12-21 04:33:28 UTC
Was able to reproduce with gcc-4.0 branch sources.  Investigating, looks like we might have a type botch somewhere...

Jeff
Comment 6 Jeffrey A. Law 2005-12-21 04:44:31 UTC
Definitely a type problem.  The Obj-C front-end is playing it too lose with types.  

main (argc, argv)
{
  char msg[100];
  int status;
  const unsigned char D.1189;
  char * msg.0;

  # BLOCK 0
  # PRED: ENTRY (fallthru)
  #   msg_3 = V_MUST_DEF <msg_2>;
  msg = "";
  msg.0_4 = &msg;               /* Mis-matched types here */
  #   VUSE <msg_3>;
  D.1189_5 = *msg.0_4;          /* And again here.  */
  return;
  # SUCC: EXIT

}

I *think* the right code is that msg.0 should have type
const unsigned char *.  In the assignment to msg.0_4 the
RHS should be casted to const unsigned char *

This is a front-end problem as far as I can tell.
Jeff
Comment 7 Jakub Jelinek 2005-12-22 09:33:28 UTC
The types are only messed up during gimplification though, into gimplify_expr
goes in both C and ObjC:
if (*(const unsigned charD.10 * {ref-all}) (const charD.1 *) &msgD.1465 != 0)
  {
    statusD.1464 = 200;
  }

Not sure why this is marked as 4.1 regression, both
4.1.0 20051214 and current gcc-4_1-branch SVN don't fail on this and gimplify
the testcase the same (correctly) in both cc1 and cc1obj and there are no ICEs
with it.
Comment 8 Jakub Jelinek 2005-12-22 23:05:27 UTC
Subject: Bug 25328

Author: jakub
Date: Thu Dec 22 23:05:20 2005
New Revision: 108982

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108982
Log:
	PR objc/25328
	* c-typeck.c (comptypes): If objc_comptypes returned < 0,
	but TYPE_MODE or TYPE_REF_CAN_ALIAS_ALL differs between t1
	and t2, make sure 0 is returned.

	* objc/execute/pr25328.m: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/objc/execute/pr25328.m
Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/c-typeck.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 9 Jakub Jelinek 2005-12-22 23:07:24 UTC
Subject: Bug 25328

Author: jakub
Date: Thu Dec 22 23:07:19 2005
New Revision: 108983

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108983
Log:
	PR objc/25328
	* objc/execute/pr25328.m: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/objc/execute/pr25328.m
Modified:
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 10 Jakub Jelinek 2005-12-22 23:09:51 UTC
Subject: Bug 25328

Author: jakub
Date: Thu Dec 22 23:09:48 2005
New Revision: 108984

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108984
Log:
	PR objc/25328
	* objc/execute/pr25328.m: New test.

Added:
    trunk/gcc/testsuite/objc/execute/pr25328.m
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 11 Jakub Jelinek 2005-12-22 23:10:39 UTC
Fixed in SVN.