Jump to content
david_navigator

Compiler doesn't issue warning - do any third part code analysis tools ?

Recommended Posts

I just discovered a nasty bug in my code. During a previous debugging session I'd commented out the use of a parameter and replaced it with a hardcoded value i.e aPort replaced with 

16000
 

procedure TAPI_Handler.ConnectDatabase(const aIPaddress: string = '192.168.42.212'; const aPort: Integer = 160000);
...
...
...
FnxWinsockTransport.Port := 16000; // aPort;

 

Surprisingly the compiler doesn't issue a hint or a warning that aPort isn't used, neither does Pascal Analyzer. Does anyone know of any third party code checking tool (maybe TMS ?) that would have picked this up ?

 

Cheers

 

David

Share this post


Link to post

Aside from that aPort should be a Word to avoid invalid port values above 65535 ... :classic_rolleyes:

 

TMS FixInsight supports a hint for this, though: O804 Method parameter ''Foo'' is declared but never used

  • Thanks 1

Share this post


Link to post
13 minutes ago, Lars Fosdal said:

Aside from that aPort should be a Word to avoid invalid port values above 65535 ..:classic_rolleyes:

 

TMS FixInsight supports a hint for this, though: O804 Method parameter ''Foo'' is declared but never used

Thanks.... and had I declared it as a Word, then the compiler would have picked up that I'd accidentally added an extra zero in to the default value (160000, rather than 16000) and I wouldn't have needed to debug and thus create my own bug !!!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×