Bug 21894 - [4.0/4.1 Regression] Invalid operand to binary operator with nested function
Summary: [4.0/4.1 Regression] Invalid operand to binary operator with nested function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: tree-ssa
: P2 normal
Target Milestone: 4.0.2
Assignee: Richard Henderson
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2005-06-02 23:23 UTC by Fariborz Jahanian
Modified: 2005-08-08 17:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-08-05 23:20:17


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fariborz Jahanian 2005-06-02 23:23:44 UTC
Following test ICEs with gcc mainline when compiled with -O1. Test was done on apple-ppc-darwin.
% gcc -c -O1 bad.c
bad.c: In function 'CheckFile':
bad.c:2: internal compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.

/* TEST */
typedef unsigned char uchar;
static void CheckFile () {
     uchar *p;
     uchar tagname[10]; uchar * a = tagname;

      void validate(uchar const * pp, uchar const * q){
        uchar const * p = pp;
        if (a == tagname+4)
          {
             uchar const * x = p;
          }
      }

      while(1){
            if(a == tagname)
              goto slip; 
              if (*p == '\"') 
                {
                  uchar const * const q = ++p; 
                  validate(q, p++);
                }
        }
  slip:
        ;
}
Comment 1 Andrew Pinski 2005-06-02 23:33:46 UTC
Confirmed, reduced testcase:
void CheckFile ()
{
     char tagname[10]; char * a = tagname;
      int validate()
      {
        return (a == tagname+4);
      }
      if(a == tagname)
        validate();
}

t.c: In function ‘CheckFile’:
t.c:11: error: Invalid operand to binary operator
FRAME.1D.1246.aD.1249;

t.c:11: 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.
Comment 2 Mark Mitchell 2005-07-06 17:02:23 UTC
Postponed until 4.0.2.
Comment 3 GCC Commits 2005-08-07 19:01:25 UTC
Subject: Bug 21894

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2005-08-07 19:01:09

Modified files:
	gcc            : ChangeLog tree-nested.c 
Added files:
	gcc/testsuite/gcc.c-torture/compile: nested-2.c 

Log message:
	PR 21894
	* tree-nested.c (convert_local_reference): Save and restore val_only
	around component_ref and friends.  Clear walk_subtrees by default.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9673&r2=2.9674
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-nested.c.diff?cvsroot=gcc&r1=2.28&r2=2.29
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/nested-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 4 GCC Commits 2005-08-08 17:32:09 UTC
Subject: Bug 21894

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	rth@gcc.gnu.org	2005-08-08 17:32:00

Modified files:
	gcc            : ChangeLog tree-nested.c 
Added files:
	gcc/testsuite/gcc.c-torture/compile: nested-2.c 

Log message:
	PR 21894
	* tree-nested.c (convert_local_reference): Save and restore val_only
	around component_ref and friends.  Clear walk_subtrees by default.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.357&r2=2.7592.2.358
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-nested.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.24&r2=2.24.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/nested-2.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 5 Richard Henderson 2005-08-08 17:32:46 UTC
Fixed.
Comment 6 Fariborz Jahanian 2005-08-08 17:36:31 UTC
Thanks. Test case should say PR 21894.
> Fixed.