Given a program with only if/else statements is it then possible to decide which variables that occur but never read?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. Given a program with only if/else statements [assuming no branches backwards and loops], there is a finite number of paths in the program.
You can check all of them, check which conditions must be met in order to get to each path, and find contradictions [un accessable paths], and this way to find which variables are never used.
This can be implemented as a simpler version of Hoare logic, which is pretty simple to automatize, without loops. [with loops it is of course impossible to automatize it]