From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1370 invoked by alias); 21 Jul 2003 16:31:17 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 1361 invoked by uid 48); 21 Jul 2003 16:31:17 -0000 Date: Mon, 21 Jul 2003 16:31:00 -0000 From: "reichelt at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20030721163114.11616.reichelt@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/11616] New: Error message "instantiated from here" gives wrong location X-Bugzilla-Reason: CC X-SW-Source: 2003-07/txt/msg02489.txt.bz2 List-Id: PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11616 Summary: Error message "instantiated from here" gives wrong location Product: gcc Version: 3.3 Status: UNCONFIRMED Keywords: diagnostic Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: reichelt at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org Consider the following invalid code: ---------------------------------------------- 1 template struct A 2 { 3 static const int i=0; 4 }; 5 6 int baz() { return A<0>::i; } 7 8 struct B 9 { 10 static void foo (int); 11 }; 12 13 template struct C 14 { 15 virtual void bar() const { T::foo(); } 16 }; 17 18 C c; ---------------------------------------------- Compiling this with g++ gives the following error message: file.cc: In member function `void C::bar() const [with T = B]': file.cc:6: instantiated from here file.cc:15: error: no matching function for call to `B::foo()' file.cc:10: note: candidates are: static void B::foo(int) The line number "6" in line 2 of the error message is obviously bogus. It should read "18" instead. The bug happened to me in a more complex situation where even the file name was wrong. In such a case it is very difficult to find the point of instantiation by hand. :-( All versions since 2.95.x seem to be affected (including 3.3 branch and mainline).