Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc_maybe_uninitialized_t test #1562

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/jmespath/jmespath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,30 @@ suite jmespath_slice_tests = [] {
};
};

// A test case for a GCC14 warning
struct gcc_maybe_uninitialized_t
{
int acc{};
int abbb{};
int cqqq{};
};

struct test_wrapper_t
{
gcc_maybe_uninitialized_t test{};
};

suite gcc_maybe_uninitialized_tests = [] {
"gcc_maybe_uninitialized"_test = [] {
using namespace std::string_view_literals;

gcc_maybe_uninitialized_t log{};

constexpr glz::opts opts{.null_terminated=0, .error_on_unknown_keys = 0};
auto ec = glz::read_jmespath<"test", opts>(log, R"({"test":{"acc":1}})"sv);
expect(not ec) << glz::format_error(ec, R"({"test":{"acc":1}})"sv);
expect(log.acc == 1);
};
};

int main() { return 0; }