Bug 29059 - [4.2 regression] ICE: verify_stmts failed (invalid operand to unary operator ""[0];)
Summary: [4.2 regression] ICE: verify_stmts failed (invalid operand to unary operator ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-checking, ice-on-valid-code, patch
: 29070 (view as bug list)
Depends on:
Blocks: 29070
  Show dependency treegraph
 
Reported: 2006-09-13 08:24 UTC by Martin Michlmayr
Modified: 2006-09-16 22:52 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-09-13 16:17:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2006-09-13 08:24:12 UTC
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, "");
};
Comment 1 Andrew Pinski 2006-09-13 16:17:26 UTC
Confirmed.
Comment 2 Janis Johnson 2006-09-13 18:13:35 UTC
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.
Comment 3 Andrew Pinski 2006-09-13 18:34:35 UTC
(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.
Comment 4 Martin Michlmayr 2006-09-13 21:33:33 UTC
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, "");
}
Comment 5 Andrew Pinski 2006-09-14 04:11:09 UTC
*** Bug 29070 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2006-09-14 04:12:28 UTC
Mine I have a patch.
set_rhs forgets to reject MODIFY_EXPRs right away.
Comment 7 Andrew Pinski 2006-09-16 22:52:20 UTC
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

Comment 8 Andrew Pinski 2006-09-16 22:52:31 UTC
Fixed.
Comment 9 Jakub Jelinek 2007-06-26 11:49:08 UTC
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