Skip to content

Commit 77edbf1

Browse files
committed
vrtexpression_exprtk.cpp: fix -Wweak-vtables clang warning
1 parent 0eb2a82 commit 77edbf1

File tree

1 file changed

+42
-38
lines changed

1 file changed

+42
-38
lines changed

frmts/vrt/vrtexpression_exprtk.cpp

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,24 @@ namespace gdal
4444
/*! @cond Doxygen_Suppress */
4545
struct vector_access_check final : public exprtk::vector_access_runtime_check
4646
{
47-
bool handle_runtime_violation(violation_context &context) override
48-
{
49-
auto nElements = (static_cast<std::uint8_t *>(context.end_ptr) -
50-
static_cast<std::uint8_t *>(context.base_ptr)) /
51-
context.type_size;
52-
auto nIndexAccessed = (static_cast<std::uint8_t *>(context.access_ptr) -
53-
static_cast<std::uint8_t *>(context.base_ptr)) /
54-
context.type_size;
55-
56-
std::ostringstream oss;
57-
oss << "Attempted to access index " << nIndexAccessed
58-
<< " in a vector of " << nElements
59-
<< " elements when evaluating VRT expression.";
60-
throw std::runtime_error(oss.str());
61-
}
47+
bool handle_runtime_violation(violation_context &context) override;
6248
};
6349

50+
bool vector_access_check::handle_runtime_violation(violation_context &context)
51+
{
52+
auto nElements = (static_cast<std::uint8_t *>(context.end_ptr) -
53+
static_cast<std::uint8_t *>(context.base_ptr)) /
54+
context.type_size;
55+
auto nIndexAccessed = (static_cast<std::uint8_t *>(context.access_ptr) -
56+
static_cast<std::uint8_t *>(context.base_ptr)) /
57+
context.type_size;
58+
59+
std::ostringstream oss;
60+
oss << "Attempted to access index " << nIndexAccessed << " in a vector of "
61+
<< nElements << " elements when evaluating VRT expression.";
62+
throw std::runtime_error(oss.str());
63+
}
64+
6465
struct loop_timeout_check final : public exprtk::loop_runtime_check
6566
{
6667
using time_point_t = std::chrono::time_point<std::chrono::steady_clock>;
@@ -95,37 +96,40 @@ struct loop_timeout_check final : public exprtk::loop_runtime_check
9596
return true;
9697
}
9798

98-
void handle_runtime_violation(const violation_context &) override
99-
{
100-
std::ostringstream oss;
101-
102-
// current version of exprtk does not report the correct
103-
// violation in case of timeout, so we track the error category
104-
// ourselves
105-
if (timeout)
106-
{
107-
oss << "Expression evaluation time exceeded maximum of "
108-
<< static_cast<double>(max_duration.count() / 1e6)
109-
<< " seconds. You can increase this threshold by setting the "
110-
<< "GDAL_EXPRTK_TIMEOUT_SECONDS configuration "
111-
<< "option.";
112-
}
113-
else
114-
{
115-
oss << "Exceeded maximum of " << max_loop_iterations
116-
<< " loop iterations.";
117-
}
118-
119-
throw std::runtime_error(oss.str());
120-
}
99+
void handle_runtime_violation(const violation_context &) override;
121100

101+
private:
122102
static constexpr size_t max_iters_per_check = 10000;
123103
size_t iterations = 0;
124104
time_point_t timeout_t{};
125105
std::chrono::microseconds max_duration{};
126106
bool timeout{false};
127107
};
128108

109+
void loop_timeout_check::handle_runtime_violation(const violation_context &)
110+
{
111+
std::ostringstream oss;
112+
113+
// current version of exprtk does not report the correct
114+
// violation in case of timeout, so we track the error category
115+
// ourselves
116+
if (timeout)
117+
{
118+
oss << "Expression evaluation time exceeded maximum of "
119+
<< static_cast<double>(max_duration.count() / 1e6)
120+
<< " seconds. You can increase this threshold by setting the "
121+
<< "GDAL_EXPRTK_TIMEOUT_SECONDS configuration "
122+
<< "option.";
123+
}
124+
else
125+
{
126+
oss << "Exceeded maximum of " << max_loop_iterations
127+
<< " loop iterations.";
128+
}
129+
130+
throw std::runtime_error(oss.str());
131+
}
132+
129133
class ExprtkExpression::Impl
130134
{
131135
public:

0 commit comments

Comments
 (0)