From aa8e04998634a78df03a6344d0cf029e9c26ec8f Mon Sep 17 00:00:00 2001 From: Christoph Hansknecht Date: Sat, 16 Sep 2023 15:09:49 +0200 Subject: [PATCH] Fix eval_jac_g error being silently ignored in TNLPAdapter::GetSpaces (#697) - throw INVALID_NLP exception now --- ChangeLog.md | 2 ++ src/Interfaces/IpTNLPAdapter.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index b36cd97bb..a9afab565 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -11,6 +11,8 @@ More detailed information about incremental changes can be found in the - Reduced priority for making Spral the default value for option linear_solver [#677]. - Adapted to change of integer types in Spral interface. Minimal required Spral version is now v2023.03.29. +- Fixed that return code from TNLP::eval_jac_g() was ignored at first call [#697, by + Christoph Hansknecht]. ### 3.14.12 (2023-04-05) diff --git a/src/Interfaces/IpTNLPAdapter.cpp b/src/Interfaces/IpTNLPAdapter.cpp index e0c6ae30d..268d0ed7c 100644 --- a/src/Interfaces/IpTNLPAdapter.cpp +++ b/src/Interfaces/IpTNLPAdapter.cpp @@ -1085,7 +1085,16 @@ bool TNLPAdapter::GetSpaces( // Get the non zero structure Index* g_iRow = new Index[nz_full_jac_g_]; Index* g_jCol = new Index[nz_full_jac_g_]; - tnlp_->eval_jac_g(n_full_x_, NULL, false, n_full_g_, nz_full_jac_g_, g_iRow, g_jCol, NULL); + + bool retval = tnlp_->eval_jac_g(n_full_x_, NULL, false, n_full_g_, nz_full_jac_g_, g_iRow, g_jCol, NULL); + + if( !retval ) + { + delete[] g_iRow; + delete[] g_jCol; + + THROW_EXCEPTION(INVALID_TNLP, "eval_jac_g returned false in GetSpaces"); + } if( index_style_ != TNLP::FORTRAN_STYLE ) {