public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98515] New: Possible regression causing "is protected within this context" error
@ 2021-01-04 16:49 belegdol at gmail dot com
2021-01-04 16:50 ` [Bug c++/98515] " belegdol at gmail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: belegdol at gmail dot com @ 2021-01-04 16:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98515
Bug ID: 98515
Summary: Possible regression causing "is protected within this
context" error
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: belegdol at gmail dot com
Target Milestone: ---
mame-0.227 has failed to compile with gcc-11 in Fedora 34 [1]
(gcc-11.0.0-0.11.fc34). mame developers have kindly provided a minimal test
case. This fails with gcc-11 but works on
class A {
public:
A() = default;
protected:
int var0 = 0;
};
template<int a> class B : public A {
public:
using A::A;
};
template<int a, int b> class C : public B<a> {
public:
using B<a>::B;
void g();
};
template<int a, int b> void C<a, b>::g()
{
A::var0++;
}
template class C<0, 0>;
While this works:
class A {
public:
A() = default;
protected:
int var0 = 0;
};
template<int a> class B : public A {
public:
using A::A;
};
template<int a, int b> class C : public B<a> {
public:
using B<a>::B;
void g() { A::var0++; }
};
template class C<0, 0>;
[1] https://github.com/mamedev/mame/issues/7616
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/98515] Possible regression causing "is protected within this context" error
2021-01-04 16:49 [Bug c++/98515] New: Possible regression causing "is protected within this context" error belegdol at gmail dot com
@ 2021-01-04 16:50 ` belegdol at gmail dot com
2021-01-04 16:50 ` belegdol at gmail dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: belegdol at gmail dot com @ 2021-01-04 16:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98515
--- Comment #1 from Julian Sikorski <belegdol at gmail dot com> ---
Created attachment 49877
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49877&action=edit
compiling test case
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/98515] Possible regression causing "is protected within this context" error
2021-01-04 16:49 [Bug c++/98515] New: Possible regression causing "is protected within this context" error belegdol at gmail dot com
2021-01-04 16:50 ` [Bug c++/98515] " belegdol at gmail dot com
@ 2021-01-04 16:50 ` belegdol at gmail dot com
2021-01-04 16:53 ` belegdol at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: belegdol at gmail dot com @ 2021-01-04 16:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98515
--- Comment #2 from Julian Sikorski <belegdol at gmail dot com> ---
Created attachment 49878
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49878&action=edit
failing test case
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/98515] Possible regression causing "is protected within this context" error
2021-01-04 16:49 [Bug c++/98515] New: Possible regression causing "is protected within this context" error belegdol at gmail dot com
2021-01-04 16:50 ` [Bug c++/98515] " belegdol at gmail dot com
2021-01-04 16:50 ` belegdol at gmail dot com
@ 2021-01-04 16:53 ` belegdol at gmail dot com
2021-01-04 20:19 ` [Bug c++/98515] [11 Regression] " mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: belegdol at gmail dot com @ 2021-01-04 16:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98515
--- Comment #3 from Julian Sikorski <belegdol at gmail dot com> ---
The initial comment meant to say: This fails with gcc-11 but works on gcc-10.2.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/98515] [11 Regression] Possible regression causing "is protected within this context" error
2021-01-04 16:49 [Bug c++/98515] New: Possible regression causing "is protected within this context" error belegdol at gmail dot com
` (2 preceding siblings ...)
2021-01-04 16:53 ` belegdol at gmail dot com
@ 2021-01-04 20:19 ` mpolacek at gcc dot gnu.org
2021-01-05 18:45 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-04 20:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98515
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
Last reconfirmed| |2021-01-04
Status|UNCONFIRMED |NEW
Priority|P3 |P1
Ever confirmed|0 |1
Summary|Possible regression causing |[11 Regression] Possible
|"is protected within this |regression causing "is
|context" error |protected within this
| |context" error
Keywords| |rejects-valid
CC| |mpolacek at gcc dot gnu.org,
| |ppalka at gcc dot gnu.org
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed. Started with r11-1350.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/98515] [11 Regression] Possible regression causing "is protected within this context" error
2021-01-04 16:49 [Bug c++/98515] New: Possible regression causing "is protected within this context" error belegdol at gmail dot com
` (3 preceding siblings ...)
2021-01-04 20:19 ` [Bug c++/98515] [11 Regression] " mpolacek at gcc dot gnu.org
@ 2021-01-05 18:45 ` ppalka at gcc dot gnu.org
2021-01-08 15:17 ` cvs-commit at gcc dot gnu.org
2021-01-08 15:19 ` ppalka at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-01-05 18:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98515
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/98515] [11 Regression] Possible regression causing "is protected within this context" error
2021-01-04 16:49 [Bug c++/98515] New: Possible regression causing "is protected within this context" error belegdol at gmail dot com
` (4 preceding siblings ...)
2021-01-05 18:45 ` ppalka at gcc dot gnu.org
@ 2021-01-08 15:17 ` cvs-commit at gcc dot gnu.org
2021-01-08 15:19 ` ppalka at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-08 15:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98515
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:98a1fb705ead9258642f2dec0431f11508a9b13c
commit r11-6553-g98a1fb705ead9258642f2dec0431f11508a9b13c
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Jan 8 10:02:04 2021 -0500
c++: Fix access checking of scoped non-static member [PR98515]
In the first testcase below, we incorrectly reject the use of the
protected non-static member A::var0 from C<int>::g() because
check_accessibility_of_qualified_id, at template parse time, determines
that the access doesn't go through 'this'. (This happens because the
dependent base B<T> of C<T> doesn't have a binfo object, so it appears
to DERIVED_FROM_P that A is not an indirect base of C<T>.) From there
we create the corresponding deferred access check, which we then
perform at instantiation time and which (expectedly) fails.
The problem ultimately seems to be that we can't in general determine
whether a use of a scoped non-static member goes through 'this' until
instantiation time, as the second testcase below illustrates. So this
patch makes check_accessibility_of_qualified_id punt in such situations
to avoid creating a bogus deferred access check.
gcc/cp/ChangeLog:
PR c++/98515
* semantics.c (check_accessibility_of_qualified_id): Punt if
we're checking access of a scoped non-static member inside a
class template.
gcc/testsuite/ChangeLog:
PR c++/98515
* g++.dg/template/access32.C: New test.
* g++.dg/template/access33.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/98515] [11 Regression] Possible regression causing "is protected within this context" error
2021-01-04 16:49 [Bug c++/98515] New: Possible regression causing "is protected within this context" error belegdol at gmail dot com
` (5 preceding siblings ...)
2021-01-08 15:17 ` cvs-commit at gcc dot gnu.org
@ 2021-01-08 15:19 ` ppalka at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-01-08 15:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98515
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
This should now be fixed on trunk; thanks for the bug report.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-01-08 15:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04 16:49 [Bug c++/98515] New: Possible regression causing "is protected within this context" error belegdol at gmail dot com
2021-01-04 16:50 ` [Bug c++/98515] " belegdol at gmail dot com
2021-01-04 16:50 ` belegdol at gmail dot com
2021-01-04 16:53 ` belegdol at gmail dot com
2021-01-04 20:19 ` [Bug c++/98515] [11 Regression] " mpolacek at gcc dot gnu.org
2021-01-05 18:45 ` ppalka at gcc dot gnu.org
2021-01-08 15:17 ` cvs-commit at gcc dot gnu.org
2021-01-08 15:19 ` ppalka 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).