st_tree icon indicating copy to clipboard operation
st_tree copied to clipboard

Compiler Warnings About Unreachable Code

Open drewr95 opened this issue 2 years ago • 1 comments

Building with Tasking Tricore v6.3r1 compiler, with C++14 as the standard, I get the following warnings:

cptc W0111: ["path/to/st_tree/include/st_tree_nodes.h" 130] statement is unreachable
cptc W0111: ["path/to/st_tree/include/st_tree_nodes.h" 723] statement is unreachable

Culprits: https://github.com/erikerlandson/st_tree/blob/5b00cc47f850c68def63ea2298ef1fdd26d5c124/include/st_tree_nodes.h#L130 https://github.com/erikerlandson/st_tree/blob/c5e184b0663ef8b1c593534435090540e2a236cb/include/st_tree_nodes.h#L723

I may have a possible solution for line 130, but I don't understand the one at line 723. Any ideas?

drewr95 avatar Mar 13 '22 00:03 drewr95

IIRC, both were to satisfy some version of the compiler that wanted a return value. It was 10 years ago :grinning:

Line 723 is probably because there is a throw right above that will always execute. Line 130 is because it's after a while(true), so it will never reach 130.

st_tree used to be backward compatible to c++98, however it now assumes >= c++11, so possibly these are no longer an issue. Maybe the warnings can be avoided with a pragma?

erikerlandson avatar Mar 13 '22 00:03 erikerlandson