What can static analysis NOT find?

  1. the use of a variable before it has been defined

  2. memory leaks

  3. unreachable (“dead”) code

  4. array bound violations


Correct Option: B

AI Explanation

To answer this question, you need to understand the concept of static analysis.

Static analysis is a technique used in software development to analyze source code or compiled code without executing it. It helps identify potential issues and vulnerabilities in the code. However, there are certain things that static analysis cannot find:

A. The use of a variable before it has been defined - Static analysis can detect if a variable is used before it has been defined, as it analyzes the code structure and dependencies.

B. Memory leaks - Static analysis is not capable of detecting memory leaks, as it requires dynamic analysis to track memory allocations and deallocations during runtime.

C. Unreachable ("dead") code - Static analysis can identify unreachable code segments, as it analyzes the control flow and dependencies within the code.

D. Array bound violations - Static analysis can detect array bound violations by analyzing the code for improper array access and index calculations.

Therefore, the correct answer is B) memory leaks. Static analysis is not capable of detecting memory leaks as it requires dynamic analysis during runtime to track memory allocations and deallocations.

Find more quizzes: