Hello,
I have a simple problem and we get this bug once/twice in a year but the impact of this bug is always huge. The problem is the following.
When we create a new function in PowerBuilder, it automatically sets the return value as integer, which the developers forget to change once in a while. Now they do declare a variable to return as long/double/decimal but seem to forget changing the return value. Let's consider the following example.
public function integer of_get_maxid ();
long ll_max_id
Select MAX(tran_id) into :ll_max_id From table_name;
//check whether value is null
If ll_max_id = 0 OR Isnull(ll_max_id) Then
ll_max_id = 0
End If
Return ll_max_id
end function
Now, the function will work fine until the records in table will reach more than 32767. And the records in table never reach to that level during the developer unit testing or during in-house QA. The issue comes into light when a client reaches more than 32767 records and then it starts corrupting the data because now the variable overflows which gives a negative number.
What I want to know is if there a tool which can detect such possible integer overflows as it seems like this is something which an automated tool can easily catch.
I think the best solution to this problem would be if PowerBuilder compiler would show a warning for such mistakes.
Thanks,
Ankur Patel