ISTQB-ATTA practice question 8 of 15

A developer has spent three days looking at a system that crashes now and then. The problem was caused by two coding faults: i. A variable was being used but had not been defined; ii. There was a ‘goto’ statement to an undefined label 1 credit [K2]

Full set: 65 questions
Answer options
A: Static analysis tool Correct answer
B: Code coverage tool
C: Dynamic analysis tool
D: Test execution tool
Correct Answer:
A. Static analysis tool
Explanation

The two faults described, using an undefined variable and a goto statement to an undefined label, are structural defects in the source code. A static analysis tool examines the code without executing it and is specifically designed to find such issues. It analyzes control flow and data flow to identify anomalies like unreachable code, violations of programming standards, and variables used before initialization. This allows for the detection and correction of these faults before the code is ever run, preventing the type of runtime crashes described in the scenario.

Why Incorrect

B. Code coverage tool: This tool measures which parts of the code were executed during testing; it does not directly find defects.
C. Dynamic analysis tool: This tool finds defects during program execution (e.g., memory leaks). While it would detect the crash, it wouldn't find the underlying static code fault as efficiently as a static analysis tool.
D. Test execution tool: This tool automates the running of tests and reporting of results. It does not analyze the code for structural faults. ---

References

1. ISTQB Advanced Level Technical Test Analyst Syllabus (Version 3.1.1

2021):

Section 2.2.1

"Static Analysis by Tools

" page 13: This section explicitly states that static analysis tools can find "Programming defects (e.g.

variables with undefined values)" and "Programming standard violations (e.g.

unreachable code

security vulnerabilities)." The goto to an undefined label is a control-flow defect that falls into this category.

2. Lattner

C.

& Adve

V. (2004). LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. Proceedings of the 2004 International Symposium on Code Generation and Optimization (CGO'04).

Section 2

"The LLVM Compiler Infrastructure": This paper discusses compiler frameworks that perform static analysis. It explains that a key role of the compiler front-end is to parse source code and build an intermediate representation

a process during which errors like undefined labels or variables are detected before any code is executed. This is the core principle of static analysis.

DOI: https://doi.org/10.1109/CGO.2004.1281665

3. Aldrich

J. (2021). 17-355/17-655/17-819: Program Analysis Courseware. Carnegie Mellon University

School of Computer Science.

Lecture 2: Dataflow Analysis

slide 11 ("Reaching Definitions"): The course material explains that dataflow analysis

a form of static analysis

is used to determine "if a variable might be uninitialized at a use." This directly addresses the first fault mentioned in the question.

Scroll to Top