Bug 29016 - [4.2 Regression] tree check: expected class 'expression', have 'exceptional' (baselink) in get_base_var, at ipa-utils.c:224
Summary: [4.2 Regression] tree check: expected class 'expression', have 'exceptional' ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P1 normal
Target Milestone: 4.2.0
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code
: 29658 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-09-11 11:22 UTC by Udo Steinberg
Modified: 2006-11-25 04:27 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-09-11 11:59:48


Attachments
Example testcase (25.43 KB, application/octet-stream)
2006-09-11 11:23 UTC, Udo Steinberg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Udo Steinberg 2006-09-11 11:22:31 UTC
ICE with gcc version 4.2.0 20060911 (experimental) when optimizing for code size. Preprocessed example code follows. Compile with: g++ -Os -c foo.cc -o foo.o
20060908 worked ok.
Comment 1 Udo Steinberg 2006-09-11 11:23:34 UTC
Created attachment 12224 [details]
Example testcase

This code triggers the bug.
Comment 2 Martin Michlmayr 2006-09-11 11:54:59 UTC
I guess you mean this ICE:

/home/uas/cvs/drops/l4/kernel/fiasco/src/kern/kern_cnt.cpp:109: internal compiler error: tree check: expected class 'expression', have 'exceptional' (baselink) in get_base_var, at ipa-utils.c:224
Please submit a full bug report,
Comment 3 Martin Michlmayr 2006-09-11 11:59:48 UTC
(sid)451:tbm@usurper: ~] x86_64-unknown-linux-gnu-g++ -c pr29016.cc
(sid)452:tbm@usurper: ~] x86_64-unknown-linux-gnu-g++ -c -O pr29016.cc
pr29016.cc:16: internal compiler error: tree check: expected class 'expression', have 'exceptional' (baselink) in get_base_var, at ipa-utils.c:224
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
zsh: exit 1     x86_64-unknown-linux-gnu-g++ -c -O pr29016.cc
(sid)453:tbm@usurper: ~] cat pr29016.cc
typedef unsigned long int Mword;
class Kern_cnt
{
private:enum
  {
    Max_slot = 2,
  };
  static Mword (*read_kcnt_fn[Max_slot]) ();
private:static Mword read_kcnt1 ();
  static Mword read_kcnt2 ();
}
__attribute__ ((packed));
Mword (*Kern_cnt::read_kcnt_fn[Max_slot]) () =
{
read_kcnt1, read_kcnt2};
(sid)454:tbm@usurper: ~]
Comment 4 Andrew Pinski 2006-09-11 15:29:43 UTC
This is why I mentioned BASELINK should be stripped.
Comment 5 Andrew Pinski 2006-09-13 06:56:54 UTC
This one works for me but I doubt it is correct:
Index: ../../gcc/ipa-utils.c
===================================================================
--- ../../gcc/ipa-utils.c       (revision 116919)
+++ ../../gcc/ipa-utils.c       (working copy)
@@ -212,6 +212,7 @@ ipa_utils_reduced_inorder (struct cgraph
 tree
 get_base_var (tree t)
 {
+  tree temp;
   if ((TREE_CODE (t) == EXC_PTR_EXPR) || (TREE_CODE (t) == FILTER_EXPR))
     return t;

@@ -221,7 +222,11 @@ get_base_var (tree t)
         && TREE_CODE (t) != FUNCTION_DECL
         && TREE_CODE (t) != CONST_DECL)
     {
-      t = TREE_OPERAND (t, 0);
+      temp = staticp (t);
+      if (temp)
+        t = temp;
+      else
+        t = TREE_OPERAND (t, 0);
     }
   return t;
 }

Comment 6 Martin Michlmayr 2006-09-18 13:50:51 UTC
Note that this bug is very frequent (compiling the Debian archive).
Comment 7 Michael Cieslinski 2006-09-18 15:39:30 UTC
I get the same ICE with this short code:

class A;
class B
{
    typedef void (*C[5]) (A *);
    static  C D;
    static void E (A*) {}
};
B::C B::D={E};

Comment 8 Michael Cieslinski 2006-09-19 08:17:23 UTC
The patch in comment #5 fixes the testcases but a make bootstrap ; make check (with only C/C++) results in two new regressions:

WARNING: program timed out.
FAIL: g++.dg/opt/pr24665.C (test for excess errors)
FAIL: gcc.c-torture/execute/20050929-1.c compilation,  -O1 
Comment 9 Mark Mitchell 2006-09-21 22:19:04 UTC
Subject: Bug 29016

Author: mmitchel
Date: Thu Sep 21 22:18:54 2006
New Revision: 117123

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117123
Log:
	PR c++/29016
	* typeck.c (build_unary_op): Don't form an ADDR_EXPR around a
	BASELINK.
	PR c++/29016
	* g++.dg/init/ptrfn1.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/init/ptrfn1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 10 Mark Mitchell 2006-09-21 22:25:59 UTC
Fixed in 4.2.0.
Comment 11 Andrew Pinski 2006-11-25 04:27:28 UTC
*** Bug 29658 has been marked as a duplicate of this bug. ***