Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 07:37 Go to next message
Anton Golubev is currently offline Anton GolubevFriend
Messages: 2
Registered: March 2021
Junior Member
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 23:30 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
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 06:19 Go to previous message
Anton Golubev is currently offline Anton GolubevFriend
Messages: 2
Registered: March 2021
Junior Member
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: Tue Apr 23 06:17:52 GMT 2024

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

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

Back to the top