public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jdonner@schedsys.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/6079: Access error message discrepancy between template & plain class
Date: Wed, 27 Mar 2002 20:46:00 -0000	[thread overview]
Message-ID: <20020328044054.30003.qmail@sources.redhat.com> (raw)


>Number:         6079
>Category:       c++
>Synopsis:       Access error message discrepancy between template & plain class
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 27 20:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     JDonner
>Release:        gcc 3.0.4
>Organization:
>Environment:
Reading specs from /usr/local/gcc304/lib/gcc-lib/i686-pc-linux-gnu/3.0.4/specs
Configured with: /home/jdonner/mk304/gcc-3.0.4/configure --prefix=/usr/local/gcc304 --enable-threads
Thread model: posix
gcc version 3.0.4
>Description:
In some circumstances g++ doesn't warn about a hidden type as directly as in others.

// badtypedef.cpp
#if defined(CASE1)
#   define TMPL_ERR_MSG
#elif defined(CASE2)
#   define TMPL_ERR_MSG
#   define TMPL_ERR_HELPER
#endif
struct Highup{Highup() {}};

class Base : public Highup {
  typedef Highup Inherited;
  struct Secret{};
public:
  Base() : Inherited() {}
};

#ifdef TMPL_ERR_MSG
template <class SomeT>
#endif
struct Derived : public Base {
  Derived(int x) : Inherited() {
#ifdef TMPL_ERR_HELPER
  Secret s;
#endif
}
};

int main() { Derived<int> d(3); }
///////////////////////////////////////

-- Normal case;

jdonner@deathstar ~> g++ badtypedef.cpp
badtypedef.cpp: In constructor `Derived::Derived(int)':
badtypedef.cpp:11: `typedef struct Highup Base::Inherited' is private
badtypedef.cpp:21: within this context


-- Making Derived a template, g++ no longer says explicitly that 
-- 'Inherited' is private;

jdonner@deathstar ~> g++ -DCASE1 badtypedef.cpp
badtypedef.cpp: In constructor `Derived<SomeT>::Derived(int) [with SomeT = int]':
badtypedef.cpp:28:   instantiated from here
badtypedef.cpp:21: `Highup' is not an immediate base class of `Derived<int>'


-- But referring to another hidden type restores the message about 'Inherited'.

jdonner@deathstar ~> g++ -DCASE2 badtypedef.cpp
badtypedef.cpp: In constructor `Derived<SomeT>::Derived(int)':
badtypedef.cpp:12: `struct Base::Secret' is private
badtypedef.cpp:23: within this context
badtypedef.cpp:11: `typedef struct Highup Base::Inherited' is private
badtypedef.cpp:23: within this context
badtypedef.cpp: In constructor `Derived<SomeT>::Derived(int) [with SomeT = int]':
badtypedef.cpp:28:   instantiated from here
badtypedef.cpp:21: `Highup' is not an immediate base class of `Derived<int>'


g++ 2.95 does the same thing except CASE2 is no different from CASE1.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-03-28  4:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-27 20:46 jdonner [this message]
2002-09-15 11:36 nathan
2003-01-22 21:24 bangerth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020328044054.30003.qmail@sources.redhat.com \
    --to=jdonner@schedsys.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).