When called with no assertions, the CAD solver would still go to work and then segfault when trying to access the first variable.
This PR adds an explicit check for this case and adds a regression.
Fixes #5534 .
void CadSolver::checkFull()
{
#ifdef CVC4_POLY_IMP
+ if (d_CAC.getConstraints().getConstraints().empty()) {
+ Trace("nl-cad") << "No constraints. Return." << std::endl;
+ return;
+ }
auto covering = d_CAC.getUnsatCover();
if (covering.empty())
{
void CadSolver::checkPartial()
{
#ifdef CVC4_POLY_IMP
+ if (d_CAC.getConstraints().getConstraints().empty()) {
+ Trace("nl-cad") << "No constraints. Return." << std::endl;
+ return;
+ }
auto covering = d_CAC.getUnsatCover(0, true);
if (covering.empty())
{
regress0/nl/issue3971.smt2
regress0/nl/issue3991.smt2
regress0/nl/issue4007-rint-uf.smt2
+ regress0/nl/issue5534-no-assertions.smt2
regress0/nl/magnitude-wrong-1020-m.smt2
regress0/nl/mult-po.smt2
regress0/nl/nia-wrong-tl.smt2
--- /dev/null
+; COMMAND-LINE: --incremental
+; EXPECT: unsat
+; EXPECT: sat
+(set-logic QF_UFNRA)
+(declare-fun r () Real)
+(declare-fun u (Real Real) Bool)
+(assert (u 0.0 (* r r)))
+(push)
+(assert (and (< r 0.0) (< 0.0 r)))
+(check-sat)
+(pop)
+(check-sat)
\ No newline at end of file