public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95074] New: Function found via ADL when it should not
@ 2020-05-12 5:17 mpolacek at gcc dot gnu.org
2020-05-12 5:18 ` [Bug c++/95074] " mpolacek at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-12 5:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95074
Bug ID: 95074
Summary: Function found via ADL when it should not
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
namespace N {
struct S { };
void f(S);
}
namespace M {
void f(int);
}
int
main ()
{
N::S s;
extern void f(char); // #1
using M::f; // #2
f(s);
}
compiles fine, but shouldn't: [basic.lookup.argdep]/3: If X (the lookup set
produced by unqualified lookup) contains
-- a block-scope function declaration that is not a using-declaration
[...]
then Y (the lookup set produced by ADL) is empty.
So the M::f here is fine but #1 should prevent ADL. But we still find N::f.
If lines #1 and #2 are switched, this test rejected.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95074] Function found via ADL when it should not
2020-05-12 5:17 [Bug c++/95074] New: Function found via ADL when it should not mpolacek at gcc dot gnu.org
@ 2020-05-12 5:18 ` mpolacek at gcc dot gnu.org
2020-05-12 5:31 ` mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-12 5:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95074
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Not a regression.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95074] Function found via ADL when it should not
2020-05-12 5:17 [Bug c++/95074] New: Function found via ADL when it should not mpolacek at gcc dot gnu.org
2020-05-12 5:18 ` [Bug c++/95074] " mpolacek at gcc dot gnu.org
@ 2020-05-12 5:31 ` mpolacek at gcc dot gnu.org
2020-05-12 8:50 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-12 5:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95074
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This is where we're confused by the function introduced by M::f:
/* We do not perform argument-dependent lookup if
normal lookup finds a non-function, in accordance
with the expected resolution of DR 218. */
else if (!args->is_empty ()
&& is_overloaded_fn (postfix_expression))
{
/* We only need to look at the first function,
because all the fns share the attribute we're
concerned with (all member fns or all local
fns). */
tree fn = get_first_fn (postfix_expression);
fn = STRIP_TEMPLATE (fn);
/* Do not do argument dependent lookup if regular
lookup finds a member function or a block-scope
function declaration. [basic.lookup.argdep]/3 */
if (!((TREE_CODE (fn) == USING_DECL && DECL_DEPENDENT_P
(fn))
|| DECL_FUNCTION_MEMBER_P (fn)
|| DECL_LOCAL_FUNCTION_P (fn)))
{
koenig_p = true;
if (!any_type_dependent_arguments_p (args))
postfix_expression
= perform_koenig_lookup (postfix_expression, args,
complain);
}
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95074] Function found via ADL when it should not
2020-05-12 5:17 [Bug c++/95074] New: Function found via ADL when it should not mpolacek at gcc dot gnu.org
2020-05-12 5:18 ` [Bug c++/95074] " mpolacek at gcc dot gnu.org
2020-05-12 5:31 ` mpolacek at gcc dot gnu.org
@ 2020-05-12 8:50 ` redi at gcc dot gnu.org
2020-05-12 15:00 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2020-05-12 8:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95074
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-05-12
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95074] Function found via ADL when it should not
2020-05-12 5:17 [Bug c++/95074] New: Function found via ADL when it should not mpolacek at gcc dot gnu.org
` (2 preceding siblings ...)
2020-05-12 8:50 ` redi at gcc dot gnu.org
@ 2020-05-12 15:00 ` mpolacek at gcc dot gnu.org
2020-05-12 20:26 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-12 15:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95074
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95074] Function found via ADL when it should not
2020-05-12 5:17 [Bug c++/95074] New: Function found via ADL when it should not mpolacek at gcc dot gnu.org
` (3 preceding siblings ...)
2020-05-12 15:00 ` mpolacek at gcc dot gnu.org
@ 2020-05-12 20:26 ` cvs-commit at gcc dot gnu.org
2020-05-12 20:27 ` mpolacek at gcc dot gnu.org
2021-12-03 0:54 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-12 20:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95074
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:90b160f8ec515f54ddc36519a6aaa60abdabdec1
commit r11-336-g90b160f8ec515f54ddc36519a6aaa60abdabdec1
Author: Marek Polacek <polacek@redhat.com>
Date: Tue May 12 14:56:13 2020 -0400
c++: Function found via ADL when it should not [PR95074]
I noticed that we don't implement [basic.lookup.argdep]/3: quite correctly;
it says "If X (the lookup set produced by unqualified lookup) contains
-- a block-scope function declaration that is not a using-declaration
[...]
then Y (the lookup set produced by ADL) is empty."
but we were still performing ADL in fn1 in the attached test. The
problem was that we were only looking at the first function in the
overload set which in this case happened to be a using-declaration, and
those don't suppress ADL. We have to look through the whole set to find
out if unqualified lookup found a block-scope function declaration, or
a member function declaration.
PR c++/95074
* parser.c (cp_parser_postfix_expression) <case CPP_OPEN_PAREN>:
When
looking for a block-scope function declaration, look through the
whole
set, not just the first function in the overload set.
* g++.dg/lookup/koenig15.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95074] Function found via ADL when it should not
2020-05-12 5:17 [Bug c++/95074] New: Function found via ADL when it should not mpolacek at gcc dot gnu.org
` (4 preceding siblings ...)
2020-05-12 20:26 ` cvs-commit at gcc dot gnu.org
@ 2020-05-12 20:27 ` mpolacek at gcc dot gnu.org
2021-12-03 0:54 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-12 20:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95074
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in GCC 11.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/95074] Function found via ADL when it should not
2020-05-12 5:17 [Bug c++/95074] New: Function found via ADL when it should not mpolacek at gcc dot gnu.org
` (5 preceding siblings ...)
2020-05-12 20:27 ` mpolacek at gcc dot gnu.org
@ 2021-12-03 0:54 ` pinskia at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 0:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95074
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-12-03 0:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 5:17 [Bug c++/95074] New: Function found via ADL when it should not mpolacek at gcc dot gnu.org
2020-05-12 5:18 ` [Bug c++/95074] " mpolacek at gcc dot gnu.org
2020-05-12 5:31 ` mpolacek at gcc dot gnu.org
2020-05-12 8:50 ` redi at gcc dot gnu.org
2020-05-12 15:00 ` mpolacek at gcc dot gnu.org
2020-05-12 20:26 ` cvs-commit at gcc dot gnu.org
2020-05-12 20:27 ` mpolacek at gcc dot gnu.org
2021-12-03 0:54 ` pinskia 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).