public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109382] New: Error inside virtual function of class template does not show point of instantiation
@ 2023-04-03 2:16 zeratul976 at hotmail dot com
2023-04-03 2:23 ` [Bug c++/109382] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: zeratul976 at hotmail dot com @ 2023-04-03 2:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109382
Bug ID: 109382
Summary: Error inside virtual function of class template does
not show point of instantiation
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zeratul976 at hotmail dot com
Target Milestone: ---
Given the following invalid code:
struct Base {
virtual void f() = 0;
};
template <typename T>
struct C : Base {
void f() override {
T().waldo();
}
};
int main() {
C<int> obj;
}
The error is printed as follows:
$ g++-12 -c test.cpp
test.cpp: In instantiation of ‘void C<T>::f() [with T = int]’:
test.cpp:6:8: required from here
test.cpp:7:9: error: request for member ‘waldo’ in ‘0’, which is of non-class
type ‘int’
7 | T().waldo();
| ~~~~^~~~~
The error is missing a "required from here" line pointing to `C<int> obj;`.
If you imagine everything above main() being library code, it can be hard for a
user to tell which line of the user's code is triggering the error in the
library.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/109382] Error inside virtual function of class template does not show point of instantiation
2023-04-03 2:16 [Bug c++/109382] New: Error inside virtual function of class template does not show point of instantiation zeratul976 at hotmail dot com
@ 2023-04-03 2:23 ` pinskia at gcc dot gnu.org
2023-04-03 2:27 ` pinskia at gcc dot gnu.org
2023-04-03 2:36 ` [Bug c++/109382] Error inside virtual function of class template does not show point of instantiation/use, only shows where the function is defined pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-03 2:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109382
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang gives:
<source>:7:8: error: member reference base type 'int' is not a structure or
union
T().waldo();
~~~^~~~~~
<source>:11:10: note: in instantiation of member function 'C<int>::f' requested
here
C<int> obj;
^
Which is definitely better.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/109382] Error inside virtual function of class template does not show point of instantiation
2023-04-03 2:16 [Bug c++/109382] New: Error inside virtual function of class template does not show point of instantiation zeratul976 at hotmail dot com
2023-04-03 2:23 ` [Bug c++/109382] " pinskia at gcc dot gnu.org
@ 2023-04-03 2:27 ` pinskia at gcc dot gnu.org
2023-04-03 2:36 ` [Bug c++/109382] Error inside virtual function of class template does not show point of instantiation/use, only shows where the function is defined pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-03 2:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109382
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2023-04-03
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced slightly more:
```
template <typename T>
struct C {
virtual void f() {
T().waldo();
}
};
int main() {
C<int> obj;
}
```
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/109382] Error inside virtual function of class template does not show point of instantiation/use, only shows where the function is defined.
2023-04-03 2:16 [Bug c++/109382] New: Error inside virtual function of class template does not show point of instantiation zeratul976 at hotmail dot com
2023-04-03 2:23 ` [Bug c++/109382] " pinskia at gcc dot gnu.org
2023-04-03 2:27 ` pinskia at gcc dot gnu.org
@ 2023-04-03 2:36 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-03 2:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109382
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 90508 in the end.
*** This bug has been marked as a duplicate of bug 90508 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-03 2:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03 2:16 [Bug c++/109382] New: Error inside virtual function of class template does not show point of instantiation zeratul976 at hotmail dot com
2023-04-03 2:23 ` [Bug c++/109382] " pinskia at gcc dot gnu.org
2023-04-03 2:27 ` pinskia at gcc dot gnu.org
2023-04-03 2:36 ` [Bug c++/109382] Error inside virtual function of class template does not show point of instantiation/use, only shows where the function is defined 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).