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

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).