How to diagnose a false positive warning
Michael Welsh Duggan via Gcc-help <[email protected]> Tue, 12 May 2026 23:43:33 -0400
| Newsgroups | gmane.comp.gcc.help |
|---|---|
| Organization | Carnegie Mellon University |
| Message-ID | <[email protected]> |
g++ 16 ends up triggering a new false positive warning in some of my
code that didn't trigger in g++ 15. An example of this warning:
In file included from /home/md5i/src/ipfix/master/tests/build.hpp:6,
from /home/md5i/src/ipfix/master/tests/read.cpp:7:
In function ‘void ipfix::convert::to_chunk_unsafe(auto:65&&, T) [with T = unsigned int; auto:65 = std::span<unsigned char>]’,
inlined from ‘build::message& build::message::set_domain(build::u32)’ at /home/md5i/src/ipfix/master/tests/build.hpp:202:29,
inlined from ‘virtual void ReadTest_EmptyMessages_Test::TestBody()’ at /home/md5i/src/ipfix/master/tests/read.cpp:262:19:
/home/md5i/src/ipfix/master/src/../include/detail/conversions.hpp:244:14: error: writing 4 bytes into a region of size 0 [-Werror=stringop-overflow=]
244 | std::memcpy(data(chunk), start, size(chunk));
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In member function ‘virtual void ReadTest_EmptyMessages_Test::TestBody()’:
cc1plus: note: destination object is likely at address zero
I'm fairly certain that this is a false positive, but the code is too
complex to reproduce here. I started to work on a minimal reproducer,
but, again, the code is quite layered and complex. I know I can ignore
the warning using diagnostic pragmas, but I prefer not to do that unless
completely necessary. Can anyone recommend a way to debug why this
warning is triggered?
--
Michael Welsh Duggan
([email protected])