public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19189] New: A derived template cannot access base template members without using this
@ 2004-12-29 14:30 amos at ilogix dot com
  2004-12-29 14:33 ` [Bug c++/19189] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: amos at ilogix dot com @ 2004-12-29 14:30 UTC (permalink / raw)
  To: gcc-bugs

If you try to access a member of a base template from a derived template (event
if the member is public) you are getting a compilation error.
This is a regression related to previous versions of the compiler (worked in
3.3.3) and I think its not ANSI C++ as well.

For example, compiling the following code (in test.cpp) will issue these errors:
$ g++ -c test.cpp 
test.cpp: In member function `virtual bool Derived<Concept>::test(Concept)':
test.cpp:21: error: `xxx' undeclared (first use this function)
test.cpp:21: error: (Each undeclared identifier is reported only once for each f
                                               unction it appears in.)

------------
test.cpp
------------
// The base template
template <class Concept> class Base 
{
public :
    int xxx;     
};

// The derived template
template <class Concept> class Derived : public Base<Concept> 
{
public :
	bool test(Concept p)
	{
        return (xxx > 10); // to fix this I need to modify it to: return
(this->xxx > 10);
    }
};

// usage
bool call_test(Derived<int>& d)
{
	return d.test(5);
}

-- 
           Summary: A derived template cannot access base template members
                    without using this
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amos at ilogix dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: gcc version 3.4.2 (mingw-special)
  GCC host triplet: MinGW on WinXP
GCC target triplet: MinGW on WinXP


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19189


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19189] A derived template cannot access base template members without using this
  2004-12-29 14:30 [Bug c++/19189] New: A derived template cannot access base template members without using this amos at ilogix dot com
@ 2004-12-29 14:33 ` pinskia at gcc dot gnu dot org
  2004-12-29 14:58 ` pinskia at physics dot uc dot edu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-29 14:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-29 14:33 -------
Does anyone read the release notes?

Yes this is required by the C++ standard.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19189


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19189] A derived template cannot access base template members without using this
  2004-12-29 14:30 [Bug c++/19189] New: A derived template cannot access base template members without using this amos at ilogix dot com
  2004-12-29 14:33 ` [Bug c++/19189] " pinskia at gcc dot gnu dot org
@ 2004-12-29 14:58 ` pinskia at physics dot uc dot edu
  2004-12-29 16:59 ` giovannibajo at libero dot it
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at physics dot uc dot edu @ 2004-12-29 14:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at physics dot uc dot edu  2004-12-29 14:58 -------
Subject: Re:  A derived template cannot access base templat e members without using this


On Dec 29, 2004, at 9:54 AM, Amos Ortal wrote:

> Hi Andrew,
>
> Thank you for your fast reply, I saw the entry in the release notes 
> but it doesn't point to the standard and I could not find it.
>
> Can you please point me to the section in the standard that specify 
> this?

14.6, the whole section is about name resolution in templates.

-- Pinski



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19189


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19189] A derived template cannot access base template members without using this
  2004-12-29 14:30 [Bug c++/19189] New: A derived template cannot access base template members without using this amos at ilogix dot com
  2004-12-29 14:33 ` [Bug c++/19189] " pinskia at gcc dot gnu dot org
  2004-12-29 14:58 ` pinskia at physics dot uc dot edu
@ 2004-12-29 16:59 ` giovannibajo at libero dot it
  2004-12-29 17:04 ` giovannibajo at libero dot it
  2004-12-30  7:33 ` amos at ilogix dot com
  4 siblings, 0 replies; 6+ messages in thread
From: giovannibajo at libero dot it @ 2004-12-29 16:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-12-29 16:59 -------
Specifically, [temp.dep]/3. Besides, even if the release notes do not point you 
to a specific place in the standard, the fact that we even documented that it's 
a *wanted* change in behaviour, it means it has to be correct, don't you think?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19189


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19189] A derived template cannot access base template members without using this
  2004-12-29 14:30 [Bug c++/19189] New: A derived template cannot access base template members without using this amos at ilogix dot com
                   ` (2 preceding siblings ...)
  2004-12-29 16:59 ` giovannibajo at libero dot it
@ 2004-12-29 17:04 ` giovannibajo at libero dot it
  2004-12-30  7:33 ` amos at ilogix dot com
  4 siblings, 0 replies; 6+ messages in thread
From: giovannibajo at libero dot it @ 2004-12-29 17:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-12-29 17:04 -------
BTW, I just added the standard reference to the release notes as well.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19189


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/19189] A derived template cannot access base template members without using this
  2004-12-29 14:30 [Bug c++/19189] New: A derived template cannot access base template members without using this amos at ilogix dot com
                   ` (3 preceding siblings ...)
  2004-12-29 17:04 ` giovannibajo at libero dot it
@ 2004-12-30  7:33 ` amos at ilogix dot com
  4 siblings, 0 replies; 6+ messages in thread
From: amos at ilogix dot com @ 2004-12-30  7:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From amos at ilogix dot com  2004-12-30 07:32 -------
(In reply to comment #3):
I agree that this is the expected behavior, although such a change, without any
backward compatibility, makes it hard to upgrade to a new version of the compiler.
In our specific case, we provide a generic library and a client that tried to
upgrade found the error and didn't understand why (they didn't read the release
notes as well). Also the error message doesn't help you to understand that this
is a deliberate change.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19189


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-12-30  7:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-29 14:30 [Bug c++/19189] New: A derived template cannot access base template members without using this amos at ilogix dot com
2004-12-29 14:33 ` [Bug c++/19189] " pinskia at gcc dot gnu dot org
2004-12-29 14:58 ` pinskia at physics dot uc dot edu
2004-12-29 16:59 ` giovannibajo at libero dot it
2004-12-29 17:04 ` giovannibajo at libero dot it
2004-12-30  7:33 ` amos at ilogix dot com

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).