Compiling as C works, C++ fails. This worked with 20060823. (sid)118:tbm@em64t: ~] /usr/lib/gcc-snapshot/bin/g++ -c -O re-ru32un.c re-ru32un.c: In function 'void LoadUserAlph(char*)': re-ru32un.c:4: error: invalid operand to unary operator ""[0]; re-ru32un.c:4: internal compiler error: verify_stmts failed Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. For Debian GNU/Linux specific bug reporting instructions, see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>. zsh: exit 1 /usr/lib/gcc-snapshot/bin/g++ -c -O re-ru32un.c (sid)119:tbm@em64t: ~] /usr/lib/gcc-snapshot/bin/g++ -c re-ru32un.c (sid)120:tbm@em64t: ~] /usr/lib/gcc-snapshot/bin/gcc -c -O re-ru32un.c (sid)121:tbm@em64t: ~] cat re-ru32un.c extern char *strcpy (char *__restrict __dest, __const char *__restrict __src); char wrkstr_un[270]; extern void LoadUserAlph (char *s) { s = wrkstr_un; strcpy (s, ""); };
Confirmed.
A regression hunt on powerpc-linux identified the following patch: http://gcc.gnu.org/viewcvs?view=rev&rev=116656 r116656 | jakub | 2006-09-02 06:55:09 +0000 (Sat, 02 Sep 2006) Interestingly enough, I've been looking into runtime failures in FreePOOMA that started with the same patch.
(In reply to comment #2) > A regression hunt on powerpc-linux identified the following patch: This is what I was expecting actually, I might look at this later, we might just need a fold (read from constant string) so we can fold ""[0] correctly.
Here's a C testcase: tbm@coconut0:~$ /usr/lib/gcc-snapshot/bin/gcc -c -O -Wwrite-strings bsdgames-input.c bsdgames-input.c: In function 'rezero': bsdgames-input.c:15: error: invalid operand to unary operator ""[0]; bsdgames-input.c:15: internal compiler error: verify_stmts failed Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. For Debian GNU/Linux specific bug reporting instructions, see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>. tbm@coconut0:~$ cat bsdgames-input.c extern char *strcpy (char *__restrict __dest, __const char *__restrict __src) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))); typedef struct { } RULE; typedef struct { char str[20]; } STACK; STACK stack[15]; int level; rezero () { level = 0; strcpy (stack[level].str, ""); }
*** Bug 29070 has been marked as a duplicate of this bug. ***
Mine I have a patch. set_rhs forgets to reject MODIFY_EXPRs right away.
Subject: Bug 29059 Author: pinskia Date: Sat Sep 16 22:52:11 2006 New Revision: 116997 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116997 Log: 2006-09-16 Andrew Pinski <pinskia@physics.uc.edu> PR tree-opt/29059 * gcc.c-torture/compile/strcpy-1.c: New test. * gcc.c-torture/compile/strcpy-2.c: New test. * gcc.c-torture/compile/memcpy-1.c: New test. * gcc.c-torture/compile/memcpy-2.c: New test. 2006-09-16 Andrew Pinski <pinskia@physics.uc.edu> PR tree-opt/29059 * tree-ssa-propagate.c (set_rhs): Reject MODIFY_EXPR right away for the expr argument. Added: trunk/gcc/testsuite/gcc.c-torture/compile/memcpy-1.c trunk/gcc/testsuite/gcc.c-torture/compile/memcpy-2.c trunk/gcc/testsuite/gcc.c-torture/compile/strcpy-1.c trunk/gcc/testsuite/gcc.c-torture/compile/strcpy-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-propagate.c
Fixed.
Subject: Bug 29059 Author: jakub Date: Tue Jun 26 11:48:55 2007 New Revision: 126024 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126024 Log: PR tree-opt/29059 * tree-ssa-propagate.c (set_rhs): Reject MODIFY_EXPR right away for the expr argument. * gcc.c-torture/compile/strcpy-1.c: New test. * gcc.c-torture/compile/strcpy-2.c: New test. * gcc.c-torture/compile/memcpy-1.c: New test. * gcc.c-torture/compile/memcpy-2.c: New test. Added: branches/redhat/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/compile/memcpy-1.c branches/redhat/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/compile/memcpy-2.c branches/redhat/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/compile/strcpy-1.c branches/redhat/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/compile/strcpy-2.c Modified: branches/redhat/gcc-4_1-branch/gcc/ChangeLog branches/redhat/gcc-4_1-branch/gcc/testsuite/ChangeLog branches/redhat/gcc-4_1-branch/gcc/tree-ssa-propagate.c