 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Duncan Guest
|
Posted: Tue Jul 20, 2004 7:53 am Post subject: C++ Lint programs |
|
|
Hello everyone,
1. Does anyone know of a free/gnu/opensource C++ lint tools? I have
seen Splint for c but I'm at a loss for anything for c++. I have
searched the list and seen unanswered posts on this topic from years
ago so a confirmatory 'NO!' would be appreciated.
2. Are lint tools relevant today? Why have modern compilers/IDEs not
absorbed this functionality?
Thanks,
Duncan
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Richard Corden Guest
|
Posted: Tue Jul 20, 2004 6:24 pm Post subject: Re: C++ Lint programs |
|
|
[email]duncan_a_woods (AT) hotmail (DOT) com[/email] (Duncan) writes:
[snip...]
| Quote: |
2. Are lint tools relevant today? Why have modern compilers/IDEs not
absorbed this functionality?
|
I may be biased as we are in the business of writing commercial static
analysis tools for C/C++ etc.
Analysis of C++ is very relevant, not so much in terms of out of
bounds array indexes, but more towards the higher level concepts in
C++.
class Base
{
public:
virtual void foo ();
};
class Derived : public Base
{
public:
virtual void foo () const; // *hides* 'Base::foo'
};
This code is legal and it might even be what the implementor intended!
However I would say its more than likely a bug!
However, I have heard it said by compiler writers that they cannot be
noisey. Their customers expect no output from the compiler for legal
code, and so no matter how silly, if it is legal, issueing a message
is not an option.
Regards,
Richard
--
Richard Corden
To reply remove 's' from address
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Peter van Merkerk Guest
|
Posted: Wed Jul 21, 2004 7:06 pm Post subject: Re: C++ Lint programs |
|
|
Richard Corden wrote:
| Quote: | duncan_a_woods (AT) hotmail (DOT) com (Duncan) writes:
Hello everyone,
[snip...]
2. Are lint tools relevant today? Why have modern compilers/IDEs not
absorbed this functionality?
I may be biased as we are in the business of writing commercial static
analysis tools for C/C++ etc.
Analysis of C++ is very relevant, not so much in terms of out of
bounds array indexes, but more towards the higher level concepts in
C++.
class Base
{
public:
virtual void foo ();
};
class Derived : public Base
{
public:
virtual void foo () const; // *hides* 'Base::foo'
};
This code is legal and it might even be what the implementor intended!
However I would say its more than likely a bug!
However, I have heard it said by compiler writers that they cannot be
noisey. Their customers expect no output from the compiler for legal
code, and so no matter how silly, if it is legal, issueing a message
is not an option.
|
I know compilers which would produce a warning when compiling the code
you posted. Usually specific warnings can be suppressed to improve the
signal-to-noise ratio. A more important reason is probably that a
thorough analysis of the code would significantly slowdown compilation.
Personally I don't mind if the compiler slaps me in the face when I'm
doing something silly but legal, as long as I can tell it to "shut up, I
know what I'm doing" and it doesn't slowdown builds to crawl.
--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Duncan Guest
|
Posted: Fri Jul 23, 2004 11:53 pm Post subject: Re: C++ Lint programs |
|
|
Thank you for responding. I wasn't necessarily thinking that static
analysis should happen at the same time as compilation but I would
have thought that MSDevBorland etc would and could include a separate
tool.
Surely a simple static analyser, capable of being given bespoke rules,
could be built upon an existing lexer without too much difficulty?
Thanks,
Duncan
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Allan W Guest
|
Posted: Fri Jul 23, 2004 11:56 pm Post subject: Re: C++ Lint programs |
|
|
[email]duncan_a_woods (AT) hotmail (DOT) com[/email] (Duncan) wrote
| Quote: | 1. Does anyone know of a free/gnu/opensource C++ lint tools? I have
seen Splint for c but I'm at a loss for anything for c++. I have
searched the list and seen unanswered posts on this topic from years
ago so a confirmatory 'NO!' would be appreciated.
|
You're not likely to get it. To give you a "confirmatory 'NO!'", someone
would have to know about *ALL* free/gnu/opensource C++ lint tools (or at
least believe that she knows about them *ALL*), AND read this message,
AND feel like answering you.
Let's put it this way. Does anybody in the world eat peanut butter on
fried squid? We might strongly suspect that the answer is no... but
unless you've recently taken a poll of all people that eat, you can
never be 100% sure.
So, until you find this all-knowing somebody, you'll have to accept a
lack of confirmatory 'YES' as evidence that the answer is *probably* NO.
There is one other way to get a confirmatory answer. Write one yourself
and make it available to the public... then you'll know for a fact that
there IS one available.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Richard Corden Guest
|
Posted: Sun Jul 25, 2004 12:30 am Post subject: Re: C++ Lint programs |
|
|
[email]duncan_a_woods (AT) hotmail (DOT) com[/email] (Duncan) writes:
| Quote: | Thank you for responding. I wasn't necessarily thinking that static
analysis should happen at the same time as compilation but I would
have thought that MSDevBorland etc would and could include a separate
tool.
Surely a simple static analyser, capable of being given bespoke rules,
could be built upon an existing lexer without too much difficulty?
|
I have to admit that I chuckled a little while reading this. It is of
course possible to perform 'simple' static analysis, but in my
experience 'simple' static analysis ends up being noisey.
Some checks are black and white, the const/non const virtual function
is a good example of a check that can be performed simply with almost
100% accuracy.
But consider the check, "Use const objects rather than MACROs for
constants".
How do we implement this? What about, find a macro that expands to a
'const integral expression' and warn!
Simple.
However, we spent a lot of time removing false positives where MACROs
were being used to perform conditional compilation, even though they
expanded to 'constant integral expressions'.
<code>
// WARNs here that __GNUC__ could be replaced by a macro!
#if (defined (__GNUC__) && (__GNUC__ >= 3))
#endif
</code>
In order to perform this check 'properly' we store Preprocessor
information with the parse tree. This information is not normally
required for compiling the code.
Regards,
Richard
--
Richard Corden
To reply remove 's' from address
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
beliavsky@aol.com Guest
|
Posted: Mon Jul 26, 2004 7:30 am Post subject: Re: C++ Lint programs |
|
|
[email]duncan_a_woods (AT) hotmail (DOT) com[/email] (Duncan) wrote in message news:<7a4c3853.0407191258.58691d90 (AT) posting (DOT) google.com>...
| Quote: | Hello everyone,
1. Does anyone know of a free/gnu/opensource C++ lint tools? I have
seen Splint for c but I'm at a loss for anything for c++. I have
searched the list and seen unanswered posts on this topic from years
ago so a confirmatory 'NO!' would be appreciated.
2. Are lint tools relevant today? Why have modern compilers/IDEs not
absorbed this functionality?
|
A related question is "Are there any subset C++ compilers?". A subset
C++ compiler, aimed primarily at beginners, would express the views of
one or more C++ experts of what features ought or ought not to be
used.
I found the the Fortran 95 subset languages F and Elf90 useful in
learning modern Fortran, although I now use only full F95 compilers
since I disagree with some of the restrictions of the subsets.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|