Skip to content

Commit

Permalink
Solve gcc13 false positive at an API level
Browse files Browse the repository at this point in the history
Introduce an explicit API call for the pattern that gcc13 dislikes.
  • Loading branch information
franzpoeschel committed Oct 2, 2024
1 parent 1a242a1 commit 9864379
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
24 changes: 24 additions & 0 deletions include/openPMD/auxiliary/JSON_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,30 @@ namespace json
return *m_positionInOriginal;
}

/**
* @brief Access the underlying JSON value
*
* @param arg See args, first arg, used to distinguish this overload.
* @param args Index to some sub-expression. Shortcut for
* `tracingJSON[arg1][arg2][arg3].json()`.
* @return nlohmann::json&
*/
template <typename Arg, typename... Args>
inline nlohmann::json &json(Arg &&arg, Args &&...args)
{
[[maybe_unused]] auto do_trace =
[subhandle = this->operator[](arg)](auto const &key) mutable {
subhandle = subhandle[key];
};
(do_trace(args), ...);
nlohmann::json *res = &m_positionInOriginal->operator[](arg);
[[maybe_unused]] auto get_res = [&res](auto const &key) {
res = &(*res)[key];
};
(get_res(args), ...);
return *res;
}

template <typename Key>
TracingJSON operator[](Key &&key);

Expand Down
2 changes: 1 addition & 1 deletion src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ adios2::Mode ADIOS2IOHandlerImpl::adios2AccessMode(std::string const &fullPath)
if (m_config.json().contains("engine") &&
m_config["engine"].json().contains("access_mode"))
{
auto const access_mode_json = m_config["engine"]["access_mode"].json();
auto const &access_mode_json = m_config.json("engine", "access_mode");
auto maybe_access_mode_string =
json::asLowerCaseStringDynamic(access_mode_json);
if (!maybe_access_mode_string.has_value())
Expand Down
4 changes: 2 additions & 2 deletions src/IO/HDF5/ParallelHDF5IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ ParallelHDF5IOHandlerImpl::ParallelHDF5IOHandlerImpl(
{
return std::nullopt;
}
auto const &val = vfd_json_config[key].json();
auto const &val = vfd_json_config.json(key);
if (val.is_number_integer())
{
return val.get<long long>();
Expand All @@ -250,7 +250,7 @@ ParallelHDF5IOHandlerImpl::ParallelHDF5IOHandlerImpl(
{
return std::nullopt;
}
auto const &val = vfd_json_config[key].json();
auto const &val = vfd_json_config.json(key);
if (auto str_val = json::asLowerCaseStringDynamic(val);
str_val.has_value())
{
Expand Down

0 comments on commit 9864379

Please sign in to comment.