public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66957] New: irregular "is protected within this context" error
@ 2015-07-21 15:24 dreamcooled at gmail dot com
  2015-07-21 17:23 ` [Bug c++/66957] [4.9/5/6 Regression] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dreamcooled at gmail dot com @ 2015-07-21 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66957
           Summary: irregular "is protected within this context" error
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dreamcooled at gmail dot com
  Target Milestone: ---

Created attachment 36023
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36023&action=edit
The code which produces the bug

In the attachment you find code which I'm trying to compile with g++.

I have a archlinux system and I have g++ version 5.1.0 from the offical repo of
my system.

I'm trying to compile the attached code by invoking 
`g++ classtest.cpp`. 

gcc fires the error:
classtest.cpp: In constructor ‘DerivedB::DerivedB()’:
classtest.cpp:9:5: error: ‘int BaseClass::x’ is protected
 int BaseClass::x;
     ^
classtest.cpp:22:32: error: within this context
         std::cout << DerivedA::x;
                                ^
What I'm trying to achieve is completely legal according to the c++ standard
([class.access.base]/p5 ).

More information, discussion, and a lot of people who agree that this is indeed
a gcc bug, can be found in the associated stackoverflow question:
http://stackoverflow.com/questions/31389470/g-compilation-error-is-protected-from-within-this-context-while-clang-do
>From gcc-bugs-return-492930-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jul 21 15:35:25 2015
Return-Path: <gcc-bugs-return-492930-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 119272 invoked by alias); 21 Jul 2015 15:35:25 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 119190 invoked by uid 55); 21 Jul 2015 15:35:21 -0000
From: "aldyh at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/66468] [6 Regression] ICE in in check_die, at dwarf2out.c:5719
Date: Tue, 21 Jul 2015 15:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: debug
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: aldyh at redhat dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: aldyh at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66468-4-wQMKlVRGI0@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66468-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66468-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg01820.txt.bz2
Content-length: 939

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf468

--- Comment #9 from Aldy Hernandez <aldyh at redhat dot com> ---
On 07/20/2015 03:14 PM, jason at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?idf468
>
> --- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
> The problem seems to be that we inlined the function, but DECL_POSSIBLY_INLINED
> remains unset, so dwarf2out doesn't think it needs to call
> dwarf2out_abstract_function.
>
> There also doesn't seem to be a cgraph edge for the inlined function call; I'm
> guessing that the function was inlined in the initial compilation, and this
> relationship is forgotten by the time we get to LTO.
>
> So, doesn't look like a dwarf2out bug.
>

Jason, thanks for looking into this.  Sorry it wasn't dwarf2out related.

Do you think perhaps we could diagnose this sort of problem earlier so
it doesn't show up (confusingly) in dwarf2out land?

Thanks.


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

* [Bug c++/66957] [4.9/5/6 Regression] irregular "is protected within this context" error
  2015-07-21 15:24 [Bug c++/66957] New: irregular "is protected within this context" error dreamcooled at gmail dot com
@ 2015-07-21 17:23 ` redi at gcc dot gnu.org
  2015-08-17 21:33 ` [Bug c++/66957] [4.9/5/6 Regression] incorrect " jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-21 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.3.6
           Keywords|                            |rejects-valid
   Last reconfirmed|                            |2015-07-21
     Ever confirmed|0                           |1
            Summary|irregular "is protected     |[4.9/5/6 Regression]
                   |within this context" error  |irregular "is protected
                   |                            |within this context" error
      Known to fail|                            |4.4.7, 4.9.3, 5.1.0, 6.0
           Severity|major                       |normal

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
class BaseClass {
protected:
  static int x;
};

struct DerivedA : BaseClass { };

struct DerivedB : BaseClass {
  DerivedB() {
    (void) DerivedA::x;
  }
};


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

* [Bug c++/66957] [4.9/5/6 Regression] incorrect "is protected within this context" error
  2015-07-21 15:24 [Bug c++/66957] New: irregular "is protected within this context" error dreamcooled at gmail dot com
  2015-07-21 17:23 ` [Bug c++/66957] [4.9/5/6 Regression] " redi at gcc dot gnu.org
@ 2015-08-17 21:33 ` jason at gcc dot gnu.org
  2015-08-18 14:44 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-08-17 21:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
         Depends on|                            |38579

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
This seems to have been broken by the fix for bug 38579.  I'll revert it in the
open release branches.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38579
[Bug 38579] [4.2/4.3/4.4 Regression] Template: Wrong inherited copy-ctor
visibility


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

* [Bug c++/66957] [4.9/5/6 Regression] incorrect "is protected within this context" error
  2015-07-21 15:24 [Bug c++/66957] New: irregular "is protected within this context" error dreamcooled at gmail dot com
                   ` (2 preceding siblings ...)
  2015-08-18 14:44 ` jason at gcc dot gnu.org
@ 2015-08-18 14:44 ` jason at gcc dot gnu.org
  2015-08-20  2:06 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-08-18 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Aug 18 14:44:06 2015
New Revision: 226975

URL: https://gcc.gnu.org/viewcvs?rev=226975&root=gcc&view=rev
Log:
        PR c++/66957
        * search.c (protected_accessible_p): Revert fix for 38579.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/inherit/access9.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/search.c
    branches/gcc-5-branch/gcc/testsuite/g++.dg/conversion/access1.C


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

* [Bug c++/66957] [4.9/5/6 Regression] incorrect "is protected within this context" error
  2015-07-21 15:24 [Bug c++/66957] New: irregular "is protected within this context" error dreamcooled at gmail dot com
  2015-07-21 17:23 ` [Bug c++/66957] [4.9/5/6 Regression] " redi at gcc dot gnu.org
  2015-08-17 21:33 ` [Bug c++/66957] [4.9/5/6 Regression] incorrect " jason at gcc dot gnu.org
@ 2015-08-18 14:44 ` jason at gcc dot gnu.org
  2015-08-18 14:44 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-08-18 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Aug 18 14:43:44 2015
New Revision: 226974

URL: https://gcc.gnu.org/viewcvs?rev=226974&root=gcc&view=rev
Log:
        PR c++/66957
        * search.c (protected_accessible_p): Revert fix for 38579.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/inherit/access9.C
Modified:
    branches/gcc-4_9-branch/gcc/cp/ChangeLog
    branches/gcc-4_9-branch/gcc/cp/search.c
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/conversion/access1.C


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

* [Bug c++/66957] [4.9/5/6 Regression] incorrect "is protected within this context" error
  2015-07-21 15:24 [Bug c++/66957] New: irregular "is protected within this context" error dreamcooled at gmail dot com
                   ` (3 preceding siblings ...)
  2015-08-18 14:44 ` jason at gcc dot gnu.org
@ 2015-08-20  2:06 ` jason at gcc dot gnu.org
  2015-08-21 11:08 ` ville.voutilainen at gmail dot com
  2015-08-22 15:37 ` Casey at Carter dot net
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2015-08-20  2:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
   Target Milestone|---                         |4.9.4

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 4.9.4, 5.3, 6.0.


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

* [Bug c++/66957] [4.9/5/6 Regression] incorrect "is protected within this context" error
  2015-07-21 15:24 [Bug c++/66957] New: irregular "is protected within this context" error dreamcooled at gmail dot com
                   ` (4 preceding siblings ...)
  2015-08-20  2:06 ` jason at gcc dot gnu.org
@ 2015-08-21 11:08 ` ville.voutilainen at gmail dot com
  2015-08-22 15:37 ` Casey at Carter dot net
  6 siblings, 0 replies; 8+ messages in thread
From: ville.voutilainen at gmail dot com @ 2015-08-21 11:08 UTC (permalink / raw)
  To: gcc-bugs

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

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ville.voutilainen at gmail dot com

--- Comment #7 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
For what it's worth, this patch looked like it might also fix
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58972, and it
does.


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

* [Bug c++/66957] [4.9/5/6 Regression] incorrect "is protected within this context" error
  2015-07-21 15:24 [Bug c++/66957] New: irregular "is protected within this context" error dreamcooled at gmail dot com
                   ` (5 preceding siblings ...)
  2015-08-21 11:08 ` ville.voutilainen at gmail dot com
@ 2015-08-22 15:37 ` Casey at Carter dot net
  6 siblings, 0 replies; 8+ messages in thread
From: Casey at Carter dot net @ 2015-08-22 15:37 UTC (permalink / raw)
  To: gcc-bugs

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

Casey Carter <Casey at Carter dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Casey at Carter dot net

--- Comment #8 from Casey Carter <Casey at Carter dot net> ---
The fix for this bug seems to have broken N4381-style customization points
(http://wg21.link/n4381). To wit, this program used to compile:

template <class T> T&& declval();

namespace X {
  namespace Y {
    int f(auto&&);

    struct fn {
      constexpr auto operator()(auto&& o) const {
        return f(o);
      }
    };
  }
  namespace {
    constexpr auto f = Y::fn{};
  }

  struct A {};

  struct B {
    friend double f(B&);
  };
}

static_assert(__is_same_as(int, decltype(X::f(declval<X::A&>()))));
static_assert(__is_same_as(double, decltype(X::f(declval<X::B&>()))));

but now results in the error "error: ‘f’ is not a member of ‘X’" for both
static_asserts. It's possible to workaround the error be declaring the
anonymous namespace inline:

inline namespace {
  constexpr auto f = Y::fn{};
}

It appears that the non-visible friend function f declared in B is incorrectly
blocking name lookup of X::f before the phase of lookup that considers
namespaces nominated by using directives (such as unnamed namespaces).
>From gcc-bugs-return-495408-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Aug 22 17:34:46 2015
Return-Path: <gcc-bugs-return-495408-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 114995 invoked by alias); 22 Aug 2015 17:34:46 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 114946 invoked by uid 48); 22 Aug 2015 17:34:42 -0000
From: "mikpelinux at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/67037] [4.9 Regression] Wrong code at -O1 and above on ARM
Date: Sat, 22 Aug 2015 17:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.3
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mikpelinux at gmail dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.4
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-67037-4-oo2UXvdCQR@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67037-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67037-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-08/txt/msg01550.txt.bz2
Content-length: 161

https://gcc.gnu.org/bugzilla/show_bug.cgi?idg037

--- Comment #3 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Started with r206023, an LRA patch.


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

end of thread, other threads:[~2015-08-22 15:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 15:24 [Bug c++/66957] New: irregular "is protected within this context" error dreamcooled at gmail dot com
2015-07-21 17:23 ` [Bug c++/66957] [4.9/5/6 Regression] " redi at gcc dot gnu.org
2015-08-17 21:33 ` [Bug c++/66957] [4.9/5/6 Regression] incorrect " jason at gcc dot gnu.org
2015-08-18 14:44 ` jason at gcc dot gnu.org
2015-08-18 14:44 ` jason at gcc dot gnu.org
2015-08-20  2:06 ` jason at gcc dot gnu.org
2015-08-21 11:08 ` ville.voutilainen at gmail dot com
2015-08-22 15:37 ` Casey at Carter dot net

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).