The C type lp_variable_t is an integer that is valid with one variable_db_t. However, in its C++ wrapper code, the Variable class is not aware of the context and thus the variable DB it belongs to.
This leads to a failing assertion in the following code:
Context ctx;
Variable x(ctx, "x");
Polynomial p1(ctx, x);
p1 *= x;
This is because the last line implicitly calls the constructor Polynomial(x) which is incorrect, as x actually belongs to ctx instead of the default context. An explicit construction with p1 *= Polynomial(ctx, x) is required instead.
Another problem occurs when indexing invalid memory in variable_db_t:
Context ctx;
Variable x(ctx, "x");
Polynomial p(x);
p *= x;
Here x is allocated in ctx's variable DB, while p is created in the default context. This leads to an out-of-bounds access in the default context's variable_db_t as the variable x was created there. No assertion fails in this case.
It would be expected that p1 is created in ctx instead of the default context.
The C type
lp_variable_tis an integer that is valid with onevariable_db_t. However, in its C++ wrapper code, theVariableclass is not aware of the context and thus the variable DB it belongs to.This leads to a failing assertion in the following code:
This is because the last line implicitly calls the constructor
Polynomial(x)which is incorrect, asxactually belongs toctxinstead of the default context. An explicit construction withp1 *= Polynomial(ctx, x)is required instead.Another problem occurs when indexing invalid memory in
variable_db_t:Here
xis allocated inctx's variable DB, whilepis created in the default context. This leads to an out-of-bounds access in the default context'svariable_db_tas the variablexwas created there. No assertion fails in this case.It would be expected that
p1is created inctxinstead of the default context.