This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Resurrecting -Wunreachable

I would like to resurrect -Wunreachable, using an algorithm which is roughly based on the Java rules for reachable statements and normal completion, augmented to deal with labels and gotos, no-return functions, statement expressions, and whatever else is relevant to C and C++. This analysis would be based mostly on syntax (except that constant folding is applied to detect trivially infinite loops), so it wouldn't suffer from the dependence on target and optimization levels the previous option had to deal with.

I think computing this information is a prerequisite for a high-quality switch warning, to detect cases that do not fall through because they do not complete normally, but this is a separate matter.

The question I have if it would be feasible right now to implement this as an early GIMPLE pass, or if I should bury this project until we have mostly eliminated early folding (Jeff Law thinks it's too difficult…).

As far as I can tell, the target dependence we have in fold right now (see <>) would not interfere too much with Java-style reachability analysis: The CFG is target-dependent, but under the Java rules, both branches of an if statement a reachable even if the condition is a compile-time constant. (It makes sense to keep this behavior because just as in Java, constant conditions are used for conditional compilation in C and C++, it's not always the preprocessor that is used for this.) So I hope that the known target dependency issues would not impact the generated warnings.


Florian Weimer / Red Hat Product Security Team

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]