https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116697
Bug ID: 116697 Summary: Bogus -Wuninitialized warning when no access to uninitialized data is done Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: andysem at mail dot ru Target Milestone: --- Consider this example: struct array { char m_buf[10]; typedef char* iterator; iterator begin() { return m_buf; } }; struct buffer { array m_buffer; array::iterator m_it; buffer() : m_it(m_buffer.begin()) {} }; Compiling this with `g++ -Wall` produces this warning: <source>: In constructor 'buffer::buffer()': <source>:15:21: warning: member 'buffer::m_buffer' is used uninitialized [-Wuninitialized] 15 | buffer() : m_it(m_buffer.begin()) {} | ^~~~~~~~ https://godbolt.org/z/Mexvadbss In this case, although the default constructor of `array` is trivial, it would have been called at the point of `buffer::m_it` construction. And even though the contents of `array::m_buf` are undefined, the code does not access it either. I think, the warning is incorrect in this case as no uninitialized data is accessed here.