[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.
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).
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.
ICE on very plausible code: P1.
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
Was able to reproduce with gcc-4.0 branch sources. Investigating, looks like we might have a type botch somewhere... Jeff
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
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.
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
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
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
Fixed in SVN.