Re: cc1plus: note: source object is likely at address zero
Jonathan Wakely via Gcc-help <[email protected]> Thu, 5 Mar 2026 15:20:36 +0000
| Newsgroups | gmane.comp.gcc.help |
|---|---|
| Message-ID | <CAH6eHdQm9oC-jXM7LEM+aeQYcuAPrO2xqwtg5n++BaEeC0vOCQ@mail.gmail.com> |
On Thu, 5 Mar 2026 at 13:43, Jonathan Grant <[email protected]> wrote: > > > > On 05/03/2026 13:31, Arsen Arsenović wrote: > > Jonny Grant <[email protected]> writes: > > > >> Is there a way to make these "notes" appear as warnings? That can then > >> be upgraded to errors by -Werror > >> [...] > >> <source>: In function 'int main()': > >> <source>:18:11: warning: 'int __builtin_puts(const char*)' reading 1 or more bytes from a region of size 0 [-Wstringop-overread] > > > > ^ That part is the actual warning, so you want > > -Werror=stringop-overread. > > > > The note is just added context for the warning (as per the usual - notes > > serve to specify more info about diagnostics). > > Hello Arsen, Andrew > > Many thanks for pointing out it's the -Wstringop-overread that causes the warning. > Maybe "from a region of size 0" is a little unclear, perahps it could be "from a region starting at address 0x0 (NULL)" Would that be a useful PR to raise? I don't think so. The warning is far more general, it says "you're reading N1 bytes from a region of N2 bytes", and in this specific case it happens to be N2 == 0. Then the note adds more context saying this specific case is probably because there's a null pointer. But the warning is supposed to be true whether the note is right or not, and deal with the general case. > > BTW, Does --param=min-pagesize=N still work? I couldn't get it to output in a recent test. It lets us et under 0x4000 as invalid addresses. > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106699#c1 > > Regards > Jonathan