Re: cc1plus: note: source object is likely at address zero
Jonathan Wakely via Gcc-help <[email protected]> Thu, 5 Mar 2026 15:22:39 +0000
| Newsgroups | gmane.comp.gcc.help |
|---|---|
| Message-ID | <CAH6eHdQXoMN_3oN90DwKyvS87YHvUKoD3SwMYOKP4kcKJOgwWA@mail.gmail.com> |
On Thu, 5 Mar 2026 at 13:34, Andrew C Aitchison via Gcc-help <[email protected]> wrote: > That godbolt link uses options > -stdc=c++23 -O1 -Wall > but I get the same output with > -std=c++11 -Og -Wstringop-overread > but with "-O0" or with no -O option at all the warning disappears. That's expected, the warning is based on data flow analysis that happens during optimization. If you disable all the optimization passes, you don't get those warnings. This is documented: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html "The effectiveness of some warnings depends on optimizations also being enabled. For example, -Wsuggest-final-types is more effective with link-time optimization. Some other warnings may not be issued at all unless optimization is enabled. While optimization in general improves the efficacy of warnings about control and data-flow problems, in some cases it may also cause false positives. "