Bug 28588 - [4.0/4.1 Regression] static private function
Summary: [4.0/4.1 Regression] static private function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.1
: P2 normal
Target Milestone: 4.2.0
Assignee: Mark Mitchell
URL:
Keywords: accepts-invalid
Depends on:
Blocks: 28991
  Show dependency treegraph
 
Reported: 2006-08-03 19:30 UTC by Evgeniy Dushistov
Modified: 2006-09-09 05:03 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.2.3
Known to fail: 3.3.3 3.4.0 4.0.0 4.1.0
Last reconfirmed: 2006-08-03 20:16:41


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evgeniy Dushistov 2006-08-03 19:30:07 UTC
$ cat test.cpp 
class Foo { static void f() {} };

int main()
{
        Foo foo;
        void (*f)();
        f = foo.f;
        return 0;
}

$ g++ -Wall test.cpp && echo "success"
success

If trying compile it with another compiler
http://cpp.sourceforge.net/?show=18471
I got something like this:

ComeauTest.c(7): error: function "Foo::f" is inaccessible
          f = foo.f;
Comment 1 Andrew Pinski 2006-08-03 20:16:41 UTC
Confirmed.
Comment 2 Mark Mitchell 2006-08-26 16:23:43 UTC
Subject: Bug 28588

Author: mmitchel
Date: Sat Aug 26 16:23:33 2006
New Revision: 116468

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116468
Log:
	PR c++/28588
	* class.c (resolve_address_of_overloaded_function): Add
	access_path parameter.  Perform access checks.
	(instantiate_type): Adjust call to
	resolve_address_of_overloaded_function.  Remove unnecessary code.
	* tree.c (is_overloaded_fn): Document.  Return 2 when there are
	acutally multiple functions.
	(really_overloaded_fn): Use is_overloaded_fn.
	* mangle.c (write_expression): Handle BASELINKs.
	* cp-tree.h (really_overloaded_fn): Return bool.
	(baselink_for_fns): Declare.
	* search.c (lookup_member): Check access for single static
	functions here.
	* pt.c (convert_nontype_argument_function): Handle BASELINKs.
	(tsubst_copy_and_build): Generate BASELINKs for template-ids.
	* semantics.c (finish_call_expr): Use baselink_for_fns.
	(baselink_for_fns): New function.
	(finish_id_expression): Use it.
	* parser.c (cp_parser_template_argument): Don't strip BASELINKs.
	PR c++/28595
	* pt.c (tsubst): Issue errors about attempts to create VLAs at
	template-instantiation time.
	PR c++/28588
	* g++.dg/inherit/access6.C: New test.
	* g++.dg/inherit/access7.C: Likewise.
	PR c++/28595
	* g++.dg/template/array15.C: New test.
	* g++.dg/template/crash2.C: Tweak error markers.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/access6.C
    trunk/gcc/testsuite/g++.dg/inherit/access7.C
    trunk/gcc/testsuite/g++.dg/template/array15.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/mangle.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/search.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/tree.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/crash2.C

Comment 3 Mark Mitchell 2006-08-26 16:34:35 UTC
Fixed in 4.2.0.  Will not be fixed in previous releases.