public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: ryan@epicgames.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/9558: subclass cannot find parent members without explicit "this->" in some cases
Date: Mon, 03 Feb 2003 23:36:00 -0000	[thread overview]
Message-ID: <20030203233023.20617.qmail@sources.redhat.com> (raw)


>Number:         9558
>Category:       c++
>Synopsis:       subclass cannot find parent members without explicit "this->" in some cases
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 03 23:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     ryan@epicgames.com
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
As this is a 23-line test case with no #includes, it'll speak best for itself, but I'll comment afterwards.

...here's the preprocessed source:

# 1 "x.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "x.cpp"

template< class T > class A
{
public:
    A() {}
    int important_value;
};

template< class T > class B : public A<T>
{
public:
    B() : A<T>()
    {
        this->important_value = 10;
        important_value = 10;
    }
};

int main(void)
{
    B<int> x();
    return(0);
}


...and here is the -v -save-temps output:

[icculus@wickedsick ~]$ gcc -v -save-temps -o x ./x.cpp
Reading specs from /usr/local/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ../gcc/configure --prefix=/usr/local/gcc-cvs
Thread model: posix
gcc version 3.4 20030203 (experimental)
 /usr/local/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -E -D__GNUG__=3 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=4 -D__GNUC_PATCHLEVEL__=0 -D_GNU_SOURCE ./x.cpp x.ii
ignoring nonexistent directory "/usr/local/gcc-cvs/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc-cvs/include/c++/3.4
 /usr/local/gcc-cvs/include/c++/3.4/i686-pc-linux-gnu
 /usr/local/gcc-cvs/include/c++/3.4/backward
 /usr/local/include
 /usr/local/gcc-cvs/include
 /usr/local/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/include
 /usr/include
End of search list.
 /usr/local/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -fpreprocessed x.ii -quiet -dumpbase x.cpp -auxbase x -version -o x.s
GNU C++ version 3.4 20030203 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 2.95.3 20010315 (release).
x.cpp: In constructor `B<T>::B()':
x.cpp:15: error: `important_value' has not been declared



The important part is B::B()'s assignments to "important_value". This gives an incorrect error stating that the member is not declared unless specifically prepended with "this->".

More notes: if "A" is not a template, or it uses a explicit type ("A<int>" instead of, "A<T>"), this error goes away, too. I assume this is just a minor detail in the new recursive-descent parser, but I'll leave real analysis to the experts.  :)

Thanks!

--ryan.

>How-To-Repeat:
Compile the example file. Result is consistent in CVS from about 12 hours ago (february 2nd, 2003).

>Fix:
I have none at this time.

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


             reply	other threads:[~2003-02-03 23:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-03 23:36 ryan [this message]
2003-02-03 23:45 bangerth
2003-02-04  0:26 Wolfgang Bangerth
2003-02-04  0:56 Wolfgang Bangerth
2003-02-04  2:36 Ryan C. Gordon
2003-02-04  2:46 Wolfgang 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=20030203233023.20617.qmail@sources.redhat.com \
    --to=ryan@epicgames.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).