Bug 11645 - [3.3/3.4 Regression] Failure to deal with using and private inheritance
Summary: [3.3/3.4 Regression] Failure to deal with using and private inheritance
Status: CLOSED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.1
: P1 critical
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2003-07-23 14:28 UTC by foskey
Modified: 2005-07-23 22:46 UTC (History)
2 users (show)

See Also:
Host: i386-pc-linux-gnu
Target: i386-pc-linux-gnu
Build: i386-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-07-23 15:07:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description foskey 2003-07-23 14:28:32 UTC
Code following works in gcc 3.2 but not in gcc 3.3.1,  worked in gcc 3.3.0.

gcctest.cpp: In member function `void INetContentTypeParameterList::Clear()':
gcctest.cpp:21: error: cannot call member function `int Container::Count()'
   without object
gcctest.cpp:22: error: cannot call member function `int Container::Count()'
   without object

Environment:
System: Linux gandalf 2.4.20 #4 Mon Apr 7 22:21:12 EST 2003 i686 GNU/Linux
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i386-linux

How-To-Repeat:
  class Contained {};

    class Container {
    public:
        int Count();
        void* Remove(int);
    };

    class List : private Container {
    public:
        using Container::Count;
        using Container::Remove;
    };

    class INetContentTypeParameterList : private List {
    public:
        void Clear();
    };

    void INetContentTypeParameterList::Clear() {
        while (Count())
            delete static_cast<Contained*>(Remove(Count() - 1));
    }

    int main() {
        INetContentTypeParameterList ilist;
        ilist.Clear();
    }
Comment 1 Andrew Pinski 2003-07-23 14:53:19 UTC
This looks valid to me but I want a second opinion.
From Phil's regression hunter:
: Search converges between 2003-06-25-trunk (#317) and 2003-06-26-trunk (#318).
: Search converges between 2003-06-25-3.3 (#149) and 2003-06-26-3.3 (#150).

Reduced sources:
    struct Container { int Count(); };
    struct List : private Container {
        using Container::Count;
    };
    struct INetContentTypeParameterList : private List { void Clear(); };
    void INetContentTypeParameterList::Clear() {
        Count();//Calling non static but in a non-static method.
    }
Comment 2 Wolfgang Bangerth 2003-07-23 15:07:48 UTC
Yes, the code is legal. The only patch in that time windows that to my layman's
eyes looks as if it could be related is this one:

2003-06-25  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10990
	* search.c (lookup_base_r): Rely on accessible_p, rather than
	trying to emulate that logic here.

	PR c++/10931
	* call.c (convert_like): Pass issue_conversion_warnings.
	(convert_like_with_context): Likewise.
	(convert_like_real): Add issue_conversion_warnings parameter.
	(perform_direct_initialization_if_possible): New function.
	* cp-tree.h (perform_direct_initialization_if_possible): Declare it.
	* typeck.c (check_for_casting_away_constness): New function.
	(build_static_cast): Rewrite.

Mark, would you mind taking a look?

W.
Comment 3 CVS Commits 2003-07-23 21:28:27 UTC
Subject: Bug 11645

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-07-23 21:28:24

Modified files:
	gcc/cp         : ChangeLog call.c cp-tree.h search.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/inherit: access4.C 

Log message:
	PR c++/11645
	* cp-tree.h (accessible_base_p): Declare.
	* call.c (build_over_call): Use it.
	* search.c (accessible_base_p): New function, split out from ...
	(lookup_base): ... here.
	
	PR c++/11645
	* g++.dg/inherit/access4.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3545&r2=1.3546
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.413&r2=1.414
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.884&r2=1.885
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&r1=1.276&r2=1.277
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2912&r2=1.2913
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/access4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 Mark Mitchell 2003-07-23 21:43:32 UTC
Fixed in GCC 3.3.1, GCC 3.4.
Comment 6 foskey 2003-07-31 01:09:17 UTC
OpenOffice.org now compiles correctly with gcc 3.3.1.  Thanks for your help.