Bytecode MEX: fix bug introduced in 8c01912a50

Use an iterator wrapped inside std::optional instead of a possibly-singular
iterator, because the latter has undefined behaviour.

By the way, pass arguments by const reference.
mr#2067
Sébastien Villemot 2022-07-26 15:52:12 +02:00
parent dc224e71ed
commit 9d84048710
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 2 additions and 1 deletions

View File

@ -29,6 +29,7 @@
#include <sstream>
#include <iostream>
#include <stack>
#include <optional>
#define _USE_MATH_DEFINES
#include <cmath>
@ -407,7 +408,7 @@ protected:
corresponding mathematical operator will be printed within braces.
The second output argument points to the tag past the expression. */
pair<string, it_code_type>
print_expression(it_code_type expr_begin, it_code_type faulty_op = {}) const
print_expression(const it_code_type &expr_begin, const optional<it_code_type> &faulty_op = nullopt) const
{
int var, lag{0}, eq;
UnaryOpcode op1;