public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110806] New: Suggest this-> for dependent base classes in more contexts
@ 2023-07-25 17:37 barry.revzin at gmail dot com
2023-07-25 17:45 ` [Bug c++/110806] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: barry.revzin at gmail dot com @ 2023-07-25 17:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110806
Bug ID: 110806
Summary: Suggest this-> for dependent base classes in more
contexts
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
Consider this [broken] program:
template <typename T>
struct Outer {
struct Inner {
template <typename F>
void wait(F f);
};
struct InnerD : Inner {
template <typename F>
void advance(F f) {
wait(f);
}
};
#ifdef OUTER
template <typename F>
void wait(F f);
#endif
};
void f(Outer<int>::InnerD i) {
i.advance(42);
}
gcc's compile error is:
<source>: In instantiation of 'void Outer<T>::InnerD::advance(F) [with F = int;
T = int]':
<source>:22:14: required from here
<source>:11:17: error: 'wait' was not declared in this scope, and no
declarations were found by argument-dependent lookup at the point of
instantiation [-fpermissive]
11 | wait(f);
| ~~~~^~~
<source>:11:17: note: declarations in dependent base 'Outer<int>::Inner' are
not found by unqualified lookup
<source>:11:17: note: use 'this->wait' instead
This is pretty good - indicates what the problem is and suggests the correct
fix.
However, if you compile with -DOUTER, such that lookup for wait(f) ends up
finding Outer<T>::f, you get this error:
<source>: In instantiation of 'void Outer<T>::InnerD::advance(F) [with F = int;
T = int]':
<source>:22:14: required from here
<source>:11:17: error: cannot call member function 'void Outer<T>::wait(F)
[with F = int; T = int]' without object
11 | wait(f);
| ~~~~^~~
If we had the exact same note in this context too, that'd be very helpful -
since if what you meant to call was Inner::wait, the fact that you cannot call
Outer::wait isn't really useful. Plus when the names of these types are a
little longer, the error message can be pretty confusing if you gloss over the
fact that the error is reporting that you tried to call void Outer<T>::wait and
not void Outer<T>::Inner::wait!
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/110806] Suggest this-> for dependent base classes in more contexts
2023-07-25 17:37 [Bug c++/110806] New: Suggest this-> for dependent base classes in more contexts barry.revzin at gmail dot com
@ 2023-07-25 17:45 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-25 17:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110806
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-25 17:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-25 17:37 [Bug c++/110806] New: Suggest this-> for dependent base classes in more contexts barry.revzin at gmail dot com
2023-07-25 17:45 ` [Bug c++/110806] " 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).