Home » Language IDEs » C / C++ IDE (CDT) » Eclipse CDT Code Analysis says error, g++ and cl.exe are OK with it(How to set the Code Analysis properly?)
Eclipse CDT Code Analysis says error, g++ and cl.exe are OK with it [message #776516] |
Sun, 08 January 2012 11:51  |
Eclipse User |
|
|
|
Code Analysis gives errors to codes that are OK, neither g++ nor cl complains about it, not even a warning.
How can I resolve these annoying issues?
Ubuntu 11.10 x86_64
CDT Build id: 20110916-0149
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
Example:
Description Resource Path Location Type
Invalid arguments '
Candidates are:
std::basic_istream<char,std::char_traits<char>> & seekg(?)
std::basic_istream<char,std::char_traits<char>> & seekg(long int, enum std::_Ios_Seekdir)
' FileAsBlockDevice.cpp /sd_card line 69 Semantic Error
p[i] = exp(a[i]+b[i]/(T+c[i]));
Description Resource Path Location Type
Invalid arguments '
Candidates are:
double exp(double)
const deriv_type exp(const deriv_type &)
' bp_calc.cpp /fw_sweep line 118 Semantic Error
|
|
| | | | | | | | | | | | |
Re: Eclipse CDT Code Analysis says error, g++ and cl.exe are OK with it [message #777180 is a reply to message #776809] |
Mon, 09 January 2012 20:28   |
Eclipse User |
|
|
|
Axel Mueller wrote on Mon, 09 January 2012 04:56The internal code analysis CODAN is bases on the indexer. So if the index is not complete you will get false CODAN errors. Sometimes the index is not complete due to missing include paths or predefined symbols which can be fixed.
In your case the indexer does not know which function to use because there are several function with the same name but different signature i.e. different parameter types.
... while the compiler certainly knows, based on the rules of the language. Otherwise there would be an ambiguity and thus an compiler error.
Generally speaking, CODAN is a very promising feature, just it doesn't seem to be "there yet". We all know that the rules of C++ can be quite intricate in all gory details. As it stands currently, CODAN doesn't seem to implement all of C++ and thus misses quite frequently things which are prefectly legal or also fails to warn on things where it should.
Just to give one very blatant example:
There is the warning "your class has virtual functions but is lacking a virtual dtor". We all agree that such a warning would be a very good thing.
Unfortunately:
- CODAN gives a false positive if your class is derived from an ABC, which defines exactly that virtual dtor
- CODAN fails to warn, when you don't declare your overriden function as "virtual", but fail to define that virtual dtor in the base class.
Of course we can start arguing about style now, but thats besides the pont.
Anyway, I think CODAN is going to be come a killer feature, once it gets most
aspects of the language right. We just need to be a bit more patient (or help with implementing what's missing?)
-- Ichthyo
|
|
| | | |
Re: Eclipse CDT Code Analysis says error, g++ and cl.exe are OK with it [message #912777 is a reply to message #777294] |
Fri, 14 September 2012 03:06   |
Eclipse User |
|
|
|
Axel Mueller wrote on Tue, 10 January 2012 03:37
Yeah, you are right. Unfortunately, there are still open issues. Therefore I have disabled some checks (e.g. virtual dtor!) and CODAN is only active when I open a file in the editor. In the Problems View I usually filter out the CODAN messages.
But work is continuing and you should see much better results with the next release in June (if you are brave you can already use a nightly build).
Thank you Axel for this information. I was not aware of the possibility of filtering codan messages in the problems view. It is much better to use problems view now.
However, as we all probably agree CODAN code analysis still is not perfect (and I'm wondering if it ever be) especially for larger Makefile projects (eg. linux kernel, qt projects, ...) so I'd like to be able to distinguish the CODAN errors from compile errors even in editor view. Is there a way how to do it? I have found only severity settings (error, warning, info). This closed bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=329430) informs about some icons used to distinguish the problems, but in Eclipse Indigo I see only red underlines and red rectangles in the bar for both compiler and CODAN errors.
I think that editor should be useful even for non indexed project...
with best regards
Jan
|
|
|
Re: Eclipse CDT Code Analysis says error, g++ and cl.exe are OK with it [message #912838 is a reply to message #912777] |
Fri, 14 September 2012 05:22   |
Eclipse User |
|
|
|
Jan Pohanka wrote on Fri, 14 September 2012 09:06
However, as we all probably agree CODAN code analysis still is not perfect (and I'm wondering if it ever be) especially for larger Makefile projects (eg. linux kernel, qt projects, ...) so I'd like to be able to distinguish the CODAN errors from compile errors even in editor view. Is there a way how to do it? I have found only severity settings (error, warning, info). This closed bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=329430) informs about some icons used to distinguish the problems, but in Eclipse Indigo I see only red underlines and red rectangles in the bar for both compiler and CODAN errors.
I think that editor should be useful even for non indexed project...
with best regards
Jan
As you can see from the above mentioned bug report I did foresee problems with the CODAN icons in the editor. Unfortunately, I was ignored. I proposed then another enhancement https://bugs.eclipse.org/bugs/show_bug.cgi?id=368221
An option to use different colors for CODAN errors in the editor. You can add your vote if you like.
|
|
| |
Re: Eclipse CDT Code Analysis says error, g++ and cl.exe are OK with it [message #1023966 is a reply to message #912861] |
Mon, 25 March 2013 11:02   |
Eclipse User |
|
|
|
I do believe that CDT Code Analysis should be switched off by default. I spent a lot of time figuring out what's wrong with my project. Of course, the code analysis was wrong, hopefully I found this and switched off that broken feature completely. But my precious time was lost and it took me an hour or so. I assume every C++ developer has to go down this path, which in overall gives years of time effort lost.
Why developers of Eclipse are keeping features that certainly are broken (such as code analysis) set default to on? It's really annoying. From my perspective I do not care, but if something is telling me that I have an error in my code, which compiles, is written perfectly fine, but some analysis went wrong - then that feature should be called experimental and removed (in my example that was reference to a type which was defined, included but Eclipse have not found it for some reason and assumed it as "?"). Certainly, the CDT Code Analysis is such feature and I ALWAYS have problems with it, thus please tell me why it's in Eclipse's stable branch and turned on by default?
[Updated on: Mon, 25 March 2013 11:05] by Moderator
|
|
|
Re: Eclipse CDT Code Analysis says error, g++ and cl.exe are OK with it [message #1024161 is a reply to message #1023966] |
Mon, 25 March 2013 19:12  |
Eclipse User |
|
|
|
Missing name Mising name wrote on Mon, 25 March 2013 11:02why it's in Eclipse's stable branch and turned on by default?
A lot of features in CDT don't work correctly. For example "Rename Refactoring" can silently break code, should it also be excluded by default?
CDT indexer is not a compiler front-end for C++ (like clang) so it often fails to parse correct code. Also CDT is far from JDT (which contains compiler) where features just work.
|
|
|
Goto Forum:
Current Time: Sun Jul 06 07:30:52 EDT 2025
Powered by FUDForum. Page generated in 0.11063 seconds
|