Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: A project should not contain unreachable code. #4634

Closed
ustchcs-bugfinder opened this issue Aug 13, 2020 · 1 comment
Closed

Bug: A project should not contain unreachable code. #4634

ustchcs-bugfinder opened this issue Aug 13, 2020 · 1 comment

Comments

@ustchcs-bugfinder
Copy link

ustchcs-bugfinder commented Aug 13, 2020

return z*10 >= nz;

       for (unsigned i = 0; i < lemmas.size(); ++i) {
            clause* cl = lemmas[i];
            if (!cl->deleted()) {
                for (literal lit : *cl) {
                    if (m_occs.contains(lit.var())) {
                        break;
                    }
                }
            }
        }

        //std::cout << "zs: " << z << " nzs: " << nz << " lemmas: " << ctx.get_lemmas().size() << " trail: " << m_card_trail.size() << "\n";
        return z*10 >= nz;   // The code next line will not be reached. There is no comment for why returning here.

        m_occs.reset();
        for (unsigned i = 0; i < lemmas.size(); ++i) {
            clause* cl = lemmas[i];
            unsigned sz = cl->get_num_literals();
            for (unsigned j = 0; j < sz; ++j) {
                unsigned idx = cl->get_literal(j).index();
                m_occs.insert(idx);
            }
        }
    }

This kind of problems are too many. It looks very causal to add return or throw statements without a /*TODO*/ or /*FIXME*/ comment to let others know what happened.

https://github.com/Z3Prover/z3/blob/master/src/ast/datatype_decl_plugin.cpp#L647
https://github.com/Z3Prover/z3/blob/master/src/ast/fpa/fpa2bv_converter.cpp#L1174
...

Reported by: USTCHCS Analysis Toolsuite Bugfinder
(bugfinder-1.1: A project should not contain unreachable code.)

NikolajBjorner added a commit that referenced this issue Aug 13, 2020
Signed-off-by: Nikolaj Bjorner <[email protected]>
@NikolajBjorner
Copy link
Contributor

Not sure where the ... are, but non-... references have if 0 guards or otherwise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants