Skip to content

unwindset parsing: Work around spurious GCC 12 warning #7540

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

Closed
Closed
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
11 changes: 8 additions & 3 deletions src/goto-instrument/unwindset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ void unwindsett::parse_unwindset_one_loop(
if(val.empty())
return;

optionalt<unsigned> thread_nr;
// we should use optionalt<unsigned> here, but then GCC 12 wrongly complains that we may be using an uninitialized variable
unsigned thread_nr = 0;
bool thread_nr_is_set = false;
if(isdigit(val[0]))
{
auto c_pos = val.find(':');
if(c_pos != std::string::npos)
{
std::string nr = val.substr(0, c_pos);
thread_nr = unsafe_string2unsigned(nr);
thread_nr_is_set = true;
val.erase(0, nr.size() + 1);
}
}
Expand Down Expand Up @@ -171,8 +174,10 @@ void unwindsett::parse_unwindset_one_loop(
else
uw = unsafe_string2unsigned(uw_string);

if(thread_nr.has_value())
thread_loop_map[std::pair<irep_idt, unsigned>(id, *thread_nr)] = uw;
if(thread_nr_is_set)
{
thread_loop_map[std::make_pair(id, thread_nr)] = uw;
}
else
loop_map[id] = uw;
}
Expand Down