Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » A non-existent function inside a template does not show an error
A non-existent function inside a template does not show an error [message #1839427] Sun, 21 March 2021 03:37 Go to next message
Eclipse UserFriend
Here is sample code:
template<typename T>
void f1(T param)
{
	f2(param);
}

int main() {
	f1(10);
}

CDT does not display any warning, but this code, of course, does not compile. Is this a feature of this IDE, or something is broken?
Re: A non-existent function inside a template does not show an error [message #1839452 is a reply to message #1839427] Sun, 21 March 2021 19:30 Go to previous messageGo to next message
Eclipse UserFriend
There is no compile error if the template is not instantiated.
Comment out f1(10); and it will compile.
This may help you understand why:
https://stackoverflow.com/questions/31328754/why-do-template-classes-allow-member-functions-which-cannot-compile

The error isn't detected until the code is compiled.
The indexer in Eclipse/CDT is not a compiler.
As far as the Indexer is concerned you are merely calling a function with known parameters.
Re: A non-existent function inside a template does not show an error [message #1839457 is a reply to message #1839452] Mon, 22 March 2021 02:19 Go to previous message
Eclipse UserFriend
Thanks for the answer, I instantiated the template on purpose to test the code assist features.
It turns out that the functionality of CDT is somewhat limited when it comes to templates. (for example vim + coc + clangd will output an error if the template is instantiated and will not output if not instantiated).
I also checked that the call from the template is not displayed in the Call Hierarchy.
Apparently, it would be quite difficult to implement such functionality, and my goal is only to make sure that nothing is broken for me.
Previous Topic:Debug error 'Interpreter `mi2' unrecognized.
Next Topic:Draw a line over function definitions?
Goto Forum:
  


Current Time: Sat Jul 12 16:55:18 EDT 2025

Powered by FUDForum. Page generated in 0.06026 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top