https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100215
Bug ID: 100215 Summary: Improve text of -Wmaybe-uninitialized references Product: gcc Version: 10.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jengelh at inai dot de Target Milestone: --- Request for enhancements on a particular warning message emitted for shoddy code. Input: ``` #include <list> #include <cstring> struct C { C() = default; C(C &&o) { memcpy(bar, o.bar, sizeof(bar)); } int foo = -1; char bar[1024]; }; int main() { C z; std::list<C>().push_back(std::move(z)); } ``` Command & observed output: ``` $ g++ -v gcc version 10.3.0 (SUSE Linux) $ g++ test.cpp -O2 -Wall t2.cpp:5:19: warning: ‘*((void*)& z +4)’ may be used uninitialized in this function [-Wmaybe-uninitialized] 5 | C(C &&o) { memcpy(bar, o.bar, sizeof(bar)); } | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ ``` The warning references the original variable name, and the caret is placed in a somewhat arbitrary position. Expected output: ``` t2.cpp:5:19: warning: ‘o.bar’ may be used uninitialized in this function [-Wmaybe-uninitialized] 5 | C(C &&o) { memcpy(bar, o.bar, sizeof(bar)); } | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ ``` - granted, z+4 is a result of the optimizer; it would be nice if it could show o+4 though - more on that, z+4/o+4 could be shown as z.bar/o.bar - caret be adjusted accordingly to point to the 2nd argument of memcpy