public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17649] New: template protected member: no visibility in derived class
@ 2004-09-24  9:01 simon dot marshall at misys dot com
  2004-09-24 11:44 ` [Bug c++/17649] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: simon dot marshall at misys dot com @ 2004-09-24  9:01 UTC (permalink / raw)
  To: gcc-bugs

If a base class has a protected member, then a derived class method should have 
access to its member.  However, for template classes only, the derived class 
does not.  (interestingly, derived class members do appear to have access to 
the member in another derived class object - just not in the this object.)  
This is a regression from 3.3.4.

[marshals@itanic marshals]$ ~/slash342/usr/local/bin/g++ -v
Reading specs from /home/marshals/slash342/usr/local/lib/gcc/ia64-redhat-
linux/3.4.2/specs
Configured with: ../configure --prefix=/home/marshals/slash342/usr/local --
enable-languages=c,c++ --enable-shared --enable-threads=posix --disable-
checking --with-system-zlib --enable-__cxa_atexit --host=ia64-redhat-linux
Thread model: posix
gcc version 3.4.2
[marshals@itanic itanic]$ ~/slash342/usr/local/bin/g++ bug1.cpp
bug1.cpp: In copy constructor `tderiv<T_t>::tderiv(const tderiv<T_t>&)':
bug1.cpp:38: error: `_foo' undeclared (first use this function)
bug1.cpp:38: error: (Each undeclared identifier is reported only once for each 
function it appears in.)
[marshals@itanic itanic]$ cat bug1.cpp
// Base class with protected member.
class base
{
public:
        base ();
        base (const base &foo);
protected:
        int _foo;
};

// Derived class that sets base's protected member.
class deriv : public base
{
public:
        deriv (const deriv &foo) {
                int bar = foo._foo;
                _foo = bar;
        }
};

// Exactly as above, except as template classes.
template <class T_t>
class tbase
{
public:
        tbase ();
        tbase (const tbase<T_t> &foo);
protected:
        int _foo;
};

template <class T_t>
class tderiv : public tbase<T_t>
{
public:
        tderiv (const tderiv<T_t> &foo) {
                int bar = foo._foo;
                _foo = bar;
                // Line above results in:
// bug1.cpp: In copy constructor `tderiv<T_t>::tderiv(const tderiv<T_t>&)':
// bug1.cpp:38: error: `_foo' undeclared (first use this function)
// bug1.cpp:38: error: (Each undeclared identifier is reported only once for 
each function it appears in.)
        }
};

int main () {
        return 0;
}

-- 
           Summary: template protected member: no visibility in derived
                    class
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: simon dot marshall at misys dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: ia64-redhat-linux


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


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

* [Bug c++/17649] template protected member: no visibility in derived class
  2004-09-24  9:01 [Bug c++/17649] New: template protected member: no visibility in derived class simon dot marshall at misys dot com
@ 2004-09-24 11:44 ` pinskia at gcc dot gnu dot org
  2004-11-05 19:28 ` bangerth at dealii dot org
  2004-11-05 19:30 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-24 11:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-24 11:44 -------
Invalid, read the release notes to see this is invalid code.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID
            Summary|template protected member:  |template protected member:
                   |no visibility in derived    |no visibility in derived
                   |class                       |class


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


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

* [Bug c++/17649] template protected member: no visibility in derived class
  2004-09-24  9:01 [Bug c++/17649] New: template protected member: no visibility in derived class simon dot marshall at misys dot com
  2004-09-24 11:44 ` [Bug c++/17649] " pinskia at gcc dot gnu dot org
@ 2004-11-05 19:28 ` bangerth at dealii dot org
  2004-11-05 19:30 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-11-05 19:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-11-05 19:27 -------
These are all duplicates of PR 15552 

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


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


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

* [Bug c++/17649] template protected member: no visibility in derived class
  2004-09-24  9:01 [Bug c++/17649] New: template protected member: no visibility in derived class simon dot marshall at misys dot com
  2004-09-24 11:44 ` [Bug c++/17649] " pinskia at gcc dot gnu dot org
  2004-11-05 19:28 ` bangerth at dealii dot org
@ 2004-11-05 19:30 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-11-05 19:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-11-05 19:30 -------
Duplicate of PR 15552. 

*** This bug has been marked as a duplicate of 15552 ***

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


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


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

end of thread, other threads:[~2004-11-05 19:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-24  9:01 [Bug c++/17649] New: template protected member: no visibility in derived class simon dot marshall at misys dot com
2004-09-24 11:44 ` [Bug c++/17649] " pinskia at gcc dot gnu dot org
2004-11-05 19:28 ` bangerth at dealii dot org
2004-11-05 19:30 ` bangerth at dealii dot org

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