public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44401]  New: GCC does not correctly hide injected class name
@ 2010-06-03 15:01 schaub-johannes at web dot de
  2010-06-03 15:33 ` [Bug c++/44401] Doesn't " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: schaub-johannes at web dot de @ 2010-06-03 15:01 UTC (permalink / raw)
  To: gcc-bugs

This code is valid, but GCC rejects it:

struct X { int X; };
int X::*p = &X::X;

// error: taking address of constructor 'X::X'

GCC apparently seems to think that X::X looks up to the injected class name,
and thus (by 3.4.3.1/1a) would name the constructor. But the name of the
non-static data member should hide the injected class name.


-- 
           Summary: GCC does not correctly hide injected class name
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schaub-johannes at web dot de
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/44401] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
@ 2010-06-03 15:33 ` pinskia at gcc dot gnu dot org
  2010-06-03 16:46 ` schaub-johannes at web dot de
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-06-03 15:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2010-06-03 15:32 -------
There was a defect report in the C++ standard about X::X; I cannot remember
what happens with a member variable being named the same as the class name
though.


-- 


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


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

* [Bug c++/44401] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
  2010-06-03 15:33 ` [Bug c++/44401] Doesn't " pinskia at gcc dot gnu dot org
@ 2010-06-03 16:46 ` schaub-johannes at web dot de
  2010-06-03 17:00 ` paolo dot carlini at oracle dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: schaub-johannes at web dot de @ 2010-06-03 16:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from schaub-johannes at web dot de  2010-06-03 16:45 -------
The Standard allows this at 9.2/13a ("In addition, if class T has a
user-declared constructor (12.1), every nonstatic data member of class T shall
have a name different from T."). In our case we don't have a user declared
constructor. 

Now we have an object name, and a class-name. The object name should hide the
class name according to 3.3.7/2. You can access the class name by using an
elaborated type specifier "class X::X" (which is not replaced by a constructor
reference either) or if you name it in a base-specifier "struct Y : X::X { };". 

C++0x adds using declarations as one further context looking up the the
*constructor* specifically (not by way of injected class names). Thus the
following names the constructors of X (but inherits no constructors):

struct Y : X { using X::X; };

It does not name the data-member "X", because the mapping from "X::X" is done
by syntactical means by the second bullet of 3.4.3.1/2. The same mapping makes
the following work in C++0x:

struct Y : X { using identity<X>::type::type; };

This shows it doesn't use the injected class name of "X" for looking up
constructors. Now, the following is valid in C++03 and C++0x:

struct Y : X { using identity<X>::type::X; };

In C++03 this is a normal using declaration that redeclares the member name to
be public in Y and which resolves to the data member. In C++0x,
3.4.3.1/1bullet4 (see DR #400) makes the lookup yield both the injected class
name and the data member (personally i always thought that a lookup can only
yield multiple declarations if all the declarations are function names, but i'm
always surprised again). 

Anyway, if in C++0x it yields both the injected class name and the data member,
should this be the *final* result, or is that result still subject of 3.4.3.1/2
making it name only the constructor? I think this is important to clarify,
since it determines the validity of the following:

struct A { private: int A; };
struct B : A { public: using A::A; };
void f() { B b; b.A; };

If "using A::A;" names the injected class name and the data member of A, this
code seems to be valid, because "A" is public as a member of B. However if we
are subjectof 3.4.3.1/2, we will have "using A::A" name the constructors of A
and thus be a no-op declaration (no constructors are inherited in this case.
And since the data member lookup result was discared, no member name is
redeclared).

Any ideas? Are there issue reports about it, or am i just missing something?


-- 


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


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

* [Bug c++/44401] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
  2010-06-03 15:33 ` [Bug c++/44401] Doesn't " pinskia at gcc dot gnu dot org
  2010-06-03 16:46 ` schaub-johannes at web dot de
@ 2010-06-03 17:00 ` paolo dot carlini at oracle dot com
  2010-06-03 18:55 ` [Bug c++/44401] [4.5/4.6 regression] " jason at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-06-03 17:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2010-06-03 17:00 -------
Jason certainly followed these developments, I remember, let's CC him.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/44401] [4.5/4.6 regression] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
                   ` (2 preceding siblings ...)
  2010-06-03 17:00 ` paolo dot carlini at oracle dot com
@ 2010-06-03 18:55 ` jason at gcc dot gnu dot org
  2010-06-07 17:51 ` jason at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-06-03 18:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jason at gcc dot gnu dot org  2010-06-03 18:55 -------
The "naming the constructor" stuff is DR 147, but I agree that this testcase
should be accepted since lookup doesn't find the injected-class-name.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-06-03 18:55:26
               date|                            |
            Summary|Doesn't correctly hide      |[4.5/4.6 regression] Doesn't
                   |injected class name         |correctly hide injected
                   |                            |class name


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


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

* [Bug c++/44401] [4.5/4.6 regression] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
                   ` (3 preceding siblings ...)
  2010-06-03 18:55 ` [Bug c++/44401] [4.5/4.6 regression] " jason at gcc dot gnu dot org
@ 2010-06-07 17:51 ` jason at gcc dot gnu dot org
  2010-06-07 20:43 ` jason at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-06-07 17:51 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-06-03 18:55:26         |2010-06-07 17:50:43
               date|                            |


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


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

* [Bug c++/44401] [4.5/4.6 regression] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
                   ` (4 preceding siblings ...)
  2010-06-07 17:51 ` jason at gcc dot gnu dot org
@ 2010-06-07 20:43 ` jason at gcc dot gnu dot org
  2010-06-07 21:28 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-06-07 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at gcc dot gnu dot org  2010-06-07 20:43 -------
Subject: Bug 44401

Author: jason
Date: Mon Jun  7 20:43:01 2010
New Revision: 160399

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160399
Log:
        PR c++/44401
        * parser.c (cp_parser_lookup_name): Fix naming the constructor.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/tc1/dr147.C


-- 


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


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

* [Bug c++/44401] [4.5/4.6 regression] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
                   ` (5 preceding siblings ...)
  2010-06-07 20:43 ` jason at gcc dot gnu dot org
@ 2010-06-07 21:28 ` jason at gcc dot gnu dot org
  2010-06-07 22:29 ` paolo dot carlini at oracle dot com
  2010-06-08  4:39 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-06-07 21:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2010-06-07 21:28 -------
Subject: Bug 44401

Author: jason
Date: Mon Jun  7 21:28:27 2010
New Revision: 160408

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160408
Log:
        PR c++/44401
        * parser.c (cp_parser_lookup_name): Fix naming the constructor.

Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/parser.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/tc1/dr147.C


-- 


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


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

* [Bug c++/44401] [4.5/4.6 regression] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
                   ` (6 preceding siblings ...)
  2010-06-07 21:28 ` jason at gcc dot gnu dot org
@ 2010-06-07 22:29 ` paolo dot carlini at oracle dot com
  2010-06-08  4:39 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-06-07 22:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from paolo dot carlini at oracle dot com  2010-06-07 22:29 -------
Thanks.


-- 


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


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

* [Bug c++/44401] [4.5/4.6 regression] Doesn't correctly hide injected class name
  2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
                   ` (7 preceding siblings ...)
  2010-06-07 22:29 ` paolo dot carlini at oracle dot com
@ 2010-06-08  4:39 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-06-08  4:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jason at gcc dot gnu dot org  2010-06-08 04:38 -------
Fixed


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.5.1


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


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

end of thread, other threads:[~2010-06-08  4:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-03 15:01 [Bug c++/44401] New: GCC does not correctly hide injected class name schaub-johannes at web dot de
2010-06-03 15:33 ` [Bug c++/44401] Doesn't " pinskia at gcc dot gnu dot org
2010-06-03 16:46 ` schaub-johannes at web dot de
2010-06-03 17:00 ` paolo dot carlini at oracle dot com
2010-06-03 18:55 ` [Bug c++/44401] [4.5/4.6 regression] " jason at gcc dot gnu dot org
2010-06-07 17:51 ` jason at gcc dot gnu dot org
2010-06-07 20:43 ` jason at gcc dot gnu dot org
2010-06-07 21:28 ` jason at gcc dot gnu dot org
2010-06-07 22:29 ` paolo dot carlini at oracle dot com
2010-06-08  4:39 ` jason at gcc dot gnu 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).