public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jan at etpmod dot phys dot tue dot nl" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/12397] New: 3.4 regression: two-stage name lookup (?) argument shadowed by global type
Date: Thu, 25 Sep 2003 09:58:00 -0000	[thread overview]
Message-ID: <20030925073445.12397.jan@etpmod.phys.tue.nl> (raw)

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: 3.4 regression: two-stage name lookup (?) argument
                    shadowed by global type
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jan at etpmod dot phys dot tue dot nl
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

struct foo { }; 
 
template <typename T> struct bar 
{ 
    bar(){} 
    int i; 
    bar (const bar<T>& foo) : i (foo.i) {} 
}; 
 
int main() 
{ 
        bar<int> b1; 
        bar<int> b2(b1); 
} 
 
With gcc-head (today) this gives: 
 
/usr/local/gcc-head/bin/g++ t.cpp 
t.cpp: In copy constructor `bar<T>::bar(const bar<T>&)': 
t.cpp:7: error: 'struct foo' has no member named 'i' 
 
Observations: 
 
It seems that in line 7 the compiler tries to access the member i 
of the global struct foo, since: 
 
1) removing struct foo solves the problem 
2) after adding a member 'int i' to struct foo the code compiles (!) 
   a member of a non-existant object seems to be accessed then. 
 
The equivalent code without templates compiles fine. 
 
Previous gcc-releases compile this code without problems. 
 
I re-read 14.6 just to be sure but assume (hope!) that this is a compiler bug. It maybe remotely 
related to the weirdness of PR12370. 
 
/usr/local/gcc-head/bin/g++ -v 
Reading specs from /usr/local/gcc-head/lib/gcc/i686-pc-linux-gnu/3.4/specs 
Configured with: ../gcc-head/configure --prefix=/usr/local/gcc-head --enable-lan 
guages=c,c++ : (reconfigured)  : (reconfigured)  : (reconfigured) 
Thread model: posix 
gcc version 3.4 20030925 (experimental)


             reply	other threads:[~2003-09-25  7:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-25  9:58 jan at etpmod dot phys dot tue dot nl [this message]
2003-09-25 15:52 ` [Bug c++/12397] [3.4 regression] two-stage name lookup " bangerth at dealii dot org
2003-09-27  5:17 ` pinskia at gcc dot gnu dot org
2003-10-20 19:50 ` bangerth at dealii dot org
2003-12-22 20:37 ` mmitchel at gcc dot gnu dot org
2003-12-22 20:55 ` cvs-commit at gcc dot gnu dot org
2003-12-22 21:01 ` mmitchel at gcc dot gnu dot org
2003-12-22 21:01 ` mmitchel at gcc dot gnu dot org

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=20030925073445.12397.jan@etpmod.phys.tue.nl \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).