Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between static analysis and semantic analysis?

Looking at Table 9 in ISO 26262-6 (2011) Road Vehicle Functional Safety Part 6 Product Development, static code analysis (1g) and semantic code analysis (1h) are listed separately as methods for verifications.

I searched for an explanation of the differences, but I did not come across anything satisfying.

Is it an over simplification to state that static analysis can use semantic analysis, but not necessarily vice versa?

In general, what is the difference between static analysis and semantic analysis?

Most descriptions of static analysis that I've seen seem to involve discussion of semantic analysis. What is static code analysis?

Thanks for your time and any possible insights and feedback.

like image 550
JustADude Avatar asked Dec 10 '13 15:12

JustADude


1 Answers

Static analysis means that the analysis runs only for a source code, does not need to run a code or provide testing inputs. Another kind in this category is dynamic analysis which actually runs a code to test given inputs.

Semantic analysis states that the analysis estimates (or computes) a meaning of a source code. Another kind in this category is syntactic analysis which only checks a shape of a source code.

In most cases, just saying semantic or syntactic analysis implies that it is also static analysis.

For example, assuming a C compiler issues two errors "missing semicolon" and "unused variables", the former is the result from (static) syntactic analysis and the latter is the result from (static) semantic analysis performed by the compiler.

like image 100
ihji Avatar answered Oct 16 '22 05:10

ihji