The upper limit of errors in this program

Is there an upper limit to the number of errors contained in this program? If the number of instructions is known, can it be said that the program cannot contain more than "n" errors? For example, how many errors can the following function contain?

double calcInterest(double amount) { return -O.07 / amount; } 

The parser will count four functions in a function, and I could count these errors:

  • incorrect syntax
  • Incorrect interest rate (business claim error)
  • incorrect calculation (must be propagated)
  • Potential Division by Zero

It is clear that the number of errors is not infinite, given the finite number of instructions. Alternatively, we can say that the function takes 2 ^ 64 inputs, and of these, how many produce the correct output. However, is there a way to formally prove the upper limit?

+4
source share
8 answers

If the error "requirement is not fulfilled by the program" , then there are no restrictions on the number of errors (per line or otherwise), since there are no restrictions on the number of requirements.

 print "hello world" 

May contain a million errors. He does not create a pink elephant. I leave this to the reader to come up with 999999 other requirements that are not satisfied by this program.

+4
source

The number of instructions has nothing to do with whether the program does what the user wants to do. I mean, look how badly the GCC is balancing my checkbook. Buggy, as everyone goes out, it's useless!

+2
source

It all depends on how you define the "error."

If you define a program as a function from some input to some output and a specification as a definition of this function, as well as an error, like any difference in exiting a specification to a given input, then yes, you can conceivably have countably endless errors - however this is a somewhat useless definition mistakes.

+1
source

The upper limit is the number of states your program may be in. Since this number is finite on real machines, you can specify states from 1 to n. For each state, you can indicate whether this state is an error or not. So yes, but even a small program with 16 bytes of memory has 2 ^ 128 states, and the problem of analyzing all the different states is unsolvable.

+1
source

There is a theoretical upper limit for errors, but for all but the simplest programs, it's almost impossible to calculate, although engines like Pex give it an old college attempt.

0
source

The law of programming:

 "If You will find all compile-time bugs, then n logical ones are still hidden, waiting to surprise You at run-time." 
0
source

Depends on how you count errors, which makes me say no, no limit. I do not know about you, but I can easily write several errors in one line of code. For example, how many errors are there in this Java code? :-P

 public int addTwoNumbers(int x, String y) {{ z == x + y; return y; } 
0
source

At a minimum, if the error is significant enough.

0
source

Source: https://habr.com/ru/post/1286792/


All Articles