Bug 26740 - [4.2 regression] ICE taking the address of a bound member function
Summary: [4.2 regression] ICE taking the address of a bound member function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (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-on-valid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2006-03-18 02:41 UTC by Volker Reichelt
Modified: 2006-06-04 17:41 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-03-18 03:08:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-03-18 02:41:59 UTC
The following testcases cause ICEs on mainline:

g++.old-deja/g++.bugs/900213_03.C
g++.old-deja/g++.other/pmf2.C
g++.old-deja/g++.other/pmf7.C

They all crash at the same position:

pmf2.C: In function 'void f()':
pmf2.C:17: error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function.  Say '&S::f'
pmf2.C:17: internal compiler error: in build_offset_ref, at cp/init.c:1353
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2006-03-18 03:08:59 UTC
Grrr.  Well confirmed.  The reason why this does show up in the testresults is because of the follow:
  fmp = &ptr->function_member;  // { dg-error "" }
        pmf = & pf->f; // { dg-error "" } not a valid pmf expression
  &a.f;                         // { dg-error "" } overloaded

Meaning dg-error should really take an argument instead of just a null string.
Comment 2 Andrew Pinski 2006-03-18 03:09:38 UTC
So who ever fixes this bug, please also fix the testsuite so the testsuite will show the ICE.
Comment 3 Volker Reichelt 2006-03-24 17:08:01 UTC
The following code should compile with -fpermissive or -fms-extensions.
So changing to ice-on-valid-code.

======================================
struct A
{
    void foo();
};

void bar()
{
    &A().foo;
}
======================================
Comment 4 Andrew Pinski 2006-04-24 01:51:33 UTC
This patch fixes the ICE for me but I don't know if it is the correct one:
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 113199)
+++ cp/typeck.c (working copy)
@@ -4208,6 +4208,7 @@ build_unary_op (enum tree_code code, tre
             and the created OFFSET_REF.  */
          tree base = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (arg, 0)));
          tree fn = get_first_fn (TREE_OPERAND (arg, 1));
+         mark_used (fn);
 
          if (! flag_ms_extensions)
            {
Comment 5 Andrew Pinski 2006-05-08 07:54:31 UTC
Mine.
Comment 6 patchapp@dberlin.org 2006-05-20 23:14:37 UTC
Subject: Bug number PR C++/26740

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-05/msg01042.html
Comment 7 Andrew Pinski 2006-06-04 17:41:06 UTC
Subject: Bug 26740

Author: pinskia
Date: Sun Jun  4 17:40:51 2006
New Revision: 114360

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114360
Log:
2006-06-01  Andrew Pinski  <pinskia@physics.uc.edu>

        PR c++/26740
        * typeck.c (build_unary_op): Mark the function as being used.


Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c

Comment 8 Andrew Pinski 2006-06-04 17:41:09 UTC
Fixed.