-
Notifications
You must be signed in to change notification settings - Fork 274
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
Conversation
GCC 12 wrongly complains about the use of an uninitialized variable. Work around by doing a poor man's version of a variable with an accompanying Boolean. The build failure was: ``` In file included from /usr/include/c++/12/bits/stl_algobase.h:64, from /usr/include/c++/12/bits/stl_tree.h:63, from /usr/include/c++/12/map:60, from ../util/symbol_table_base.h:9, from ../util/symbol_table.h:9, from ../goto-programs/goto_model.h:15, from unwindset.h:15, from unwindset.cpp:9: In constructor ‘constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = std::__cxx11::basic_string<char>&; _U2 = unsigned int&; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = true; _T1 = dstringt; _T2 = unsigned int]’, inlined from ‘void unwindsett::parse_unwindset_one_loop(std::string, message_handlert&)’ at unwindset.cpp:174:28: /usr/include/c++/12/bits/stl_pair.h:535:42: error: ‘*(unsigned int*)((char*)&thread_nr + offsetof(nonstd::optional_lite::optionalt<unsigned int>,nonstd::optional_lite::optional<unsigned int>::contained))’ may be used uninitialized [-Werror=maybe-uninitialized] 535 | : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ unwindset.cpp: In member function ‘void unwindsett::parse_unwindset_one_loop(std::string, message_handlert&)’: unwindset.cpp:39:23: note: ‘*(unsigned int*)((char*)&thread_nr + offsetof(nonstd::optional_lite::optionalt<unsigned int>,nonstd::optional_lite::optional<unsigned int>::contained))’ was declared here 35 | optionalt<unsigned> thread_nr; | ^~~~~~~~~ ``` when using GCC 12: g++ (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frustrating but understandable.
Would it be better if instead of complicating the code to suppress the warning, we just suppressed the warning using a #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
write(foo, bar, baz);
#pragma GCC diagnostic pop ? |
I would much prefer suppressing the warning rather than working around it by removing usage of |
Codecov ReportBase: 78.49% // Head: 78.49% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #7540 +/- ##
========================================
Coverage 78.49% 78.49%
========================================
Files 1667 1667
Lines 191437 191440 +3
========================================
+ Hits 150261 150264 +3
Misses 41176 41176
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Alternative approach here - #7542 |
Closing in favour of #7542. |
GCC 12 wrongly complains about the use of an uninitialized variable. Work around by doing a poor man's version of a variable with an accompanying Boolean.
The build failure was:
when using GCC 12: g++ (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)