public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/38579]  New: Template: Wrong inherited copy-ctor visibility
@ 2008-12-19 13:01 syntheticpp at gmx dot net
  2008-12-21 23:08 ` [Bug c++/38579] [4.2/4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: syntheticpp at gmx dot net @ 2008-12-19 13:01 UTC (permalink / raw)
  To: gcc-bugs

The code below compiles, but it should give an error, because the Policy ctor
is not accessible when inheriting protected from Policy 
To have valid C++ code the inheritance must be public.


struct Policy
{
protected:
        Policy() {}
        Policy(const Policy&) {}
};

template<int I, class P>
struct BugGcc :
        protected P
        //public P
{
        BugGcc() {}

        template<int I, class P>
        BugGcc(const BugGcc<I, P>& t) : P(t) {}
};

void foo()
{
        BugGcc<0, Policy> f1;
        BugGcc<1, Policy> f2(f1);
}


GCC:
gcc-Version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC)


-- 
           Summary: Template: Wrong inherited copy-ctor visibility
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: syntheticpp at gmx dot net


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
@ 2008-12-21 23:08 ` pinskia at gcc dot gnu dot org
  2008-12-21 23:12 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-21 23:08 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
           Keywords|                            |accepts-invalid
      Known to fail|                            |4.3.0 4.0.0 4.4.0
      Known to work|                            |3.3
            Summary|Template: Wrong inherited   |[4.2/4.3/4.4 Regression]
                   |copy-ctor visibility        |Template: Wrong inherited
                   |                            |copy-ctor visibility
   Target Milestone|---                         |4.2.5


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
  2008-12-21 23:08 ` [Bug c++/38579] [4.2/4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
@ 2008-12-21 23:12 ` pinskia at gcc dot gnu dot org
  2008-12-29 22:31 ` rguenth at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-21 23:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-12-21 23:10 -------
Confirmed, related to PR 26693.

Here is the correct testcase (the testcase below does not compile with 4.4 but
for a different reason than the real bug):
struct Policy
{
protected:
        Policy() {}
        Policy(const Policy&) {}
};

template<int I, class P>
struct BugGcc :
        protected P
        //public P
{
        BugGcc() {}

        template<int I1, class P1>
        BugGcc(const BugGcc<I1, P1>& t) : P(t) {}
};

void foo()
{
        BugGcc<0, Policy> f1;
        BugGcc<1, Policy> f2(f1);
}


-- 

pinskia 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         |2008-12-21 23:10:28
               date|                            |


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
  2008-12-21 23:08 ` [Bug c++/38579] [4.2/4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
  2008-12-21 23:12 ` pinskia at gcc dot gnu dot org
@ 2008-12-29 22:31 ` rguenth at gcc dot gnu dot org
  2009-01-14 16:37 ` jason at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-29 22:31 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (2 preceding siblings ...)
  2008-12-29 22:31 ` rguenth at gcc dot gnu dot org
@ 2009-01-14 16:37 ` jason at gcc dot gnu dot org
  2009-01-14 18:29 ` syntheticpp at gmx dot net
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-14 16:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jason at gcc dot gnu dot org  2009-01-14 16:37 -------
11.2:                                                                          
           If a class is declared to be a base class for another class using
the protected access specifier, the public and protected members of the base
class are accessible as protected members of the derived class.

Not a bug.


-- 

jason at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (3 preceding siblings ...)
  2009-01-14 16:37 ` jason at gcc dot gnu dot org
@ 2009-01-14 18:29 ` syntheticpp at gmx dot net
  2009-01-15 18:56 ` syntheticpp at gmx dot net
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: syntheticpp at gmx dot net @ 2009-01-14 18:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from syntheticpp at gmx dot net  2009-01-14 18:29 -------
11.2 is talking about a different case.

When you instantiate the integer template parameter manually you will see that
it is really a bug:

struct Policy
{
protected:
    Policy() {}
    Policy(const Policy&) {}
};


template<class P>
struct BugGcc0 :
        protected P
        //public P
{
    BugGcc0() {}
};


template<class P>
struct BugGcc1 : public P
{
    BugGcc1() {}

    template<class P1>
    BugGcc1(const BugGcc0<P1>& t) : P(t) {}
};

void foo()
{
    BugGcc0<Policy> d0;
    BugGcc1<Policy> d1(d0);
}


The Policy ctor is visible within BugGcc1 (because it is inherited protected)
but it is not visible to a different class (again, because it is inherited
protected).

BugGcc0 and BugGcc1 only have the same base class but they are NOT of same type
which 11.2 talks about.

The protected policy ctor is only visible for BugGcc0 but not for BugGcc1.


-- 

syntheticpp at gmx dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |syntheticpp at gmx dot net
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (4 preceding siblings ...)
  2009-01-14 18:29 ` syntheticpp at gmx dot net
@ 2009-01-15 18:56 ` syntheticpp at gmx dot net
  2009-01-16  6:17 ` jason at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: syntheticpp at gmx dot net @ 2009-01-15 18:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from syntheticpp at gmx dot net  2009-01-15 18:56 -------
It has nothing to do with templates.

This code still compiles:

struct P 
{
protected:
    P() {}
    P(const P&) {}
};

struct B : protected P
{
    B() {}
};

struct C : public P
{
    C(const B& b) : P(b) {}
};

void foo()
{
    B b;
    C c(b);

    //P p(b); // <-- compiler error
}

But I it should not, because only within the scope of B
B "is a" P. Globally B "is not a" P. Therefore you can't pass
a instance of B in a scope different to B to the constructor 
of P. 
Even when C inherits from P the struct B is still "not a" P
in the scope of C.


-- 


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (5 preceding siblings ...)
  2009-01-15 18:56 ` syntheticpp at gmx dot net
@ 2009-01-16  6:17 ` jason at gcc dot gnu dot org
  2009-01-16  6:42 ` jason at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-16  6:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at gcc dot gnu dot org  2009-01-16 06:17 -------
Ah yes, I see.  The bug is not with the visibility of the copy ctor, but with
the conversion from B to P in order to call it.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|4.3.0 4.0.0 4.4.0           |3.4.6 4.3.0 4.0.0 4.4.0


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (7 preceding siblings ...)
  2009-01-16  6:42 ` jason at gcc dot gnu dot org
@ 2009-01-16  6:42 ` jason at gcc dot gnu dot org
  2009-01-16 18:35 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-16  6:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2009-01-16 06:41 -------
This bug was introduced by the fix for PR 10990.


-- 


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (6 preceding siblings ...)
  2009-01-16  6:17 ` jason at gcc dot gnu dot org
@ 2009-01-16  6:42 ` jason at gcc dot gnu dot org
  2009-01-16  6:42 ` jason at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-16  6:42 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|REOPENED                    |ASSIGNED
   Last reconfirmed|2008-12-21 23:10:28         |2009-01-16 06:42:05
               date|                            |


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (8 preceding siblings ...)
  2009-01-16  6:42 ` jason at gcc dot gnu dot org
@ 2009-01-16 18:35 ` jason at gcc dot gnu dot org
  2009-01-16 18:55 ` jason at gcc dot gnu dot org
  2009-01-16 18:58 ` jason at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-16 18:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2009-01-16 18:35 -------
Subject: Bug 38579

Author: jason
Date: Fri Jan 16 18:35:28 2009
New Revision: 143439

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143439
Log:
        PR c++/38579
        * search.c (protected_accessible_p): N doesn't vary.

Added:
    trunk/gcc/testsuite/g++.dg/conversion/access1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/search.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (9 preceding siblings ...)
  2009-01-16 18:35 ` jason at gcc dot gnu dot org
@ 2009-01-16 18:55 ` jason at gcc dot gnu dot org
  2009-01-16 18:58 ` jason at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-16 18:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jason at gcc dot gnu dot org  2009-01-16 18:55 -------
Fixed for 4.4, not applying to older branches.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
  2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
                   ` (10 preceding siblings ...)
  2009-01-16 18:55 ` jason at gcc dot gnu dot org
@ 2009-01-16 18:58 ` jason at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-16 18:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jason at gcc dot gnu dot org  2009-01-16 18:58 -------
*** Bug 35640 has been marked as a duplicate of this bug. ***


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrs at apple dot com


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


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

* [Bug c++/38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor visibility
       [not found] <bug-38579-4@http.gcc.gnu.org/bugzilla/>
@ 2015-08-20  2:07 ` jason at gcc dot gnu.org
  0 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2015-08-20  2:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38579

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> ---
Note that this will be broken again in 4.9.4 and 5.3, because the fix caused
the worse bug 66957 and so I reverted it on those branches.  6.0 will have a
proper fix.


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

end of thread, other threads:[~2015-08-20  2:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-19 13:01 [Bug c++/38579] New: Template: Wrong inherited copy-ctor visibility syntheticpp at gmx dot net
2008-12-21 23:08 ` [Bug c++/38579] [4.2/4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
2008-12-21 23:12 ` pinskia at gcc dot gnu dot org
2008-12-29 22:31 ` rguenth at gcc dot gnu dot org
2009-01-14 16:37 ` jason at gcc dot gnu dot org
2009-01-14 18:29 ` syntheticpp at gmx dot net
2009-01-15 18:56 ` syntheticpp at gmx dot net
2009-01-16  6:17 ` jason at gcc dot gnu dot org
2009-01-16  6:42 ` jason at gcc dot gnu dot org
2009-01-16  6:42 ` jason at gcc dot gnu dot org
2009-01-16 18:35 ` jason at gcc dot gnu dot org
2009-01-16 18:55 ` jason at gcc dot gnu dot org
2009-01-16 18:58 ` jason at gcc dot gnu dot org
     [not found] <bug-38579-4@http.gcc.gnu.org/bugzilla/>
2015-08-20  2:07 ` jason at gcc dot gnu.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).