public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103177] New: incorrect error message for ambiguous lookup
@ 2021-11-10 19:15 jens.maurer at gmx dot net
2021-11-10 19:36 ` [Bug c++/103177] " redi at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jens.maurer at gmx dot net @ 2021-11-10 19:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103177
Bug ID: 103177
Summary: incorrect error message for ambiguous lookup
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jens.maurer at gmx dot net
Target Milestone: ---
This is clearly a case of ambiguous lookup:
struct B {
static int foo(int);
};
struct B2 {
int foo();
};
struct D : private B, public B2 {
};
void f()
{
D d;
d.foo();
}
Yet, gcc complains about an inaccessible member. (Note that access is checked
at the end of overload resolution, but we should never get to that point.)
g++ -Wfatal-errors x.cc
x.cc: In function ‘void f()’:
x.cc:18:5: error: ‘static int B::foo(int)’ is inaccessible within this
context
18 | d.foo();
| ^~~
compilation terminated due to -Wfatal-errors.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/103177] incorrect error message for ambiguous lookup
2021-11-10 19:15 [Bug c++/103177] New: incorrect error message for ambiguous lookup jens.maurer at gmx dot net
@ 2021-11-10 19:36 ` redi at gcc dot gnu.org
2021-11-11 0:03 ` [Bug c++/103177] incorrect error message for ambiguous lookup with a static member function from a private base pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-10 19:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103177
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-11-10
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/103177] incorrect error message for ambiguous lookup with a static member function from a private base
2021-11-10 19:15 [Bug c++/103177] New: incorrect error message for ambiguous lookup jens.maurer at gmx dot net
2021-11-10 19:36 ` [Bug c++/103177] " redi at gcc dot gnu.org
@ 2021-11-11 0:03 ` pinskia at gcc dot gnu.org
2022-03-15 12:51 ` cvs-commit at gcc dot gnu.org
2022-03-15 12:52 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-11 0:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103177
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|incorrect error message for |incorrect error message for
|ambiguous lookup |ambiguous lookup with a
| |static member function from
| |a private base
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So if I remove static from B::foo, the inaccessible error message is gone.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/103177] incorrect error message for ambiguous lookup with a static member function from a private base
2021-11-10 19:15 [Bug c++/103177] New: incorrect error message for ambiguous lookup jens.maurer at gmx dot net
2021-11-10 19:36 ` [Bug c++/103177] " redi at gcc dot gnu.org
2021-11-11 0:03 ` [Bug c++/103177] incorrect error message for ambiguous lookup with a static member function from a private base pinskia at gcc dot gnu.org
@ 2022-03-15 12:51 ` cvs-commit at gcc dot gnu.org
2022-03-15 12:52 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-15 12:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103177
--- Comment #2 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:ffe9c0a0d3564a6083ea6194eb3374a89c29c085
commit r12-7656-gffe9c0a0d3564a6083ea6194eb3374a89c29c085
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Mar 15 08:50:24 2022 -0400
c++: extraneous access error with ambiguous lookup [PR103177]
When a lookup is ambiguous, lookup_member still attempts to check
access of the first member found before diagnosing the ambiguity and
propagating the error, and this may cause us to issue an extraneous
access error as in the testcase below (for B1::foo).
This patch fixes this by swapping the order of the ambiguity and access
checks within lookup_member. In passing, since the only thing that could
go wrong during lookup_field_r is ambiguity, we might as well hardcode
that in lookup_member and get rid of lookup_field_info::errstr.
PR c++/103177
gcc/cp/ChangeLog:
* search.cc (lookup_field_info::errstr): Remove this data
member.
(lookup_field_r): Don't set errstr.
(lookup_member): Check ambiguity before checking access.
Simplify accordingly after errstr removal. Exit early upon
error or empty result.
gcc/testsuite/ChangeLog:
* g++.dg/lookup/ambig6.C: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/103177] incorrect error message for ambiguous lookup with a static member function from a private base
2021-11-10 19:15 [Bug c++/103177] New: incorrect error message for ambiguous lookup jens.maurer at gmx dot net
` (2 preceding siblings ...)
2022-03-15 12:51 ` cvs-commit at gcc dot gnu.org
@ 2022-03-15 12:52 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-03-15 12:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103177
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |12.0
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
CC| |ppalka at gcc dot gnu.org
Status|NEW |RESOLVED
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-15 12:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 19:15 [Bug c++/103177] New: incorrect error message for ambiguous lookup jens.maurer at gmx dot net
2021-11-10 19:36 ` [Bug c++/103177] " redi at gcc dot gnu.org
2021-11-11 0:03 ` [Bug c++/103177] incorrect error message for ambiguous lookup with a static member function from a private base pinskia at gcc dot gnu.org
2022-03-15 12:51 ` cvs-commit at gcc dot gnu.org
2022-03-15 12:52 ` 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).