public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8875: Ambiguities in mixed template hierarchies
@ 2002-12-09 11:42 bangerth
0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2002-12-09 11:42 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, pawig
Synopsis: Ambiguities in mixed template hierarchies
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Mon Dec 9 11:42:08 2002
State-Changed-Why:
I am inclined to say this is indeed a bug. Member functions
that can only be reached through private inheritance should
not be considered during name lookup here.
It has nothing to do with two-stage lookup.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8875
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/8875: Ambiguities in mixed template hierarchies
@ 2002-12-10 2:09 nathan
0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2002-12-10 2:09 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, pawig
Synopsis: Ambiguities in mixed template hierarchies
State-Changed-From-To: analyzed->closed
State-Changed-By: nathan
State-Changed-When: Tue Dec 10 02:09:38 2002
State-Changed-Why:
not a bug. accessibility is considered after visibility. See [11]/4
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8875
^ permalink raw reply [flat|nested] 3+ messages in thread
* c++/8875: Ambiguities in mixed template hierarchies
@ 2002-12-08 10:56 pawig
0 siblings, 0 replies; 3+ messages in thread
From: pawig @ 2002-12-08 10:56 UTC (permalink / raw)
To: gcc-gnats
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2931 bytes --]
>Number: 8875
>Category: c++
>Synopsis: Ambiguities in mixed template hierarchies
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Sun Dec 08 10:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Stefan Große Pawig
>Release: gcc (GCC) 3.2.1 (also with 3.2)
>Organization:
>Environment:
Linux rigel 2.4.18 #5 Thu Aug 1 22:19:10 CEST 2002 i686 unknown
>Description:
The following code snippet (see below) exercises a base class
template with concrete and pure virtual methods as well as
general and specialized derived templates, which provide
implementations for the pure virtual methods.
Spezializations are provided for void* as well as for pointers
in general, which builds on the void* spezialization via
private inheritance.
The problem occurs when one of the concrete methods of the base
class is called on an instantiation of the derived template for
pointers (Derviced<int*> in the sample code): the compiler
complains that the concrete member is ambiguous (line 37).
Using explicit qualification works for Base<int*>::doThat() but
fails for Base<void*>::doThat() as expected (line 39), so
why does the compiler regard the unqualified call as ambiguous?
Am I missing something here? Or is this an effect of the
"Two stage lookup in templates is not implemented." as stated
on the "GCC Bugs" page?
>How-To-Repeat:
pawig@rigel:~/src > cat ctest1.cc
// Base class template
template <typename T>
class Base
{
public:
virtual T doThis() const = 0;
bool doThat() const { return doThis() == T(); }
};
// General Derived class template
template <typename T>
class Derived : public Base<T>
{
public:
T doThis() const { return T(); }
};
// Derived specialized for void*
template<>
class Derived<void*> : public Base<void*>
{
public:
void* doThis() const { return reinterpret_cast<void*>(0x0badbeef); }
};
// Derived specialized for any pointer
template <typename T>
class Derived<T*> : public Base<T*>, private Derived<void*>
{
public:
T* doThis() const { return static_cast<T*>(Derived<void*>::doThis()); }
};
int main()
{
Derived<int*> d;
bool b1 = d.doThat(); // Line 37
bool b2 = d.Base<int*>::doThat();
bool b3 = d.Base<void*>::doThat(); // Line 39
return 0;
}
pawig@rigel:~/src > g++ -c ctest1.cc
ctest1.cc: In function `int main()':
ctest1.cc:37: request for member `doThat' is ambiguous
ctest1.cc:7: candidates are: bool Base<T>::doThat() const [with T = void*]
ctest1.cc:7: bool Base<T>::doThat() const [with T = int*]
ctest1.cc:39: `Base<void*>' is an inaccessible base of `Derived<int*>'
>Fix:
Workaround:
Instead of deriving Derived<T*> privately from Derived<void*>,
just put a Derived<void*> data meber into the Derived<T*> template.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-12-10 10:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-09 11:42 c++/8875: Ambiguities in mixed template hierarchies bangerth
-- strict thread matches above, loose matches on Subject: below --
2002-12-10 2:09 nathan
2002-12-08 10:56 pawig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).