cc1plus: note: source object is likely at address zero

Jonny Grant <[email protected]> Thu, 5 Mar 2026 13:08:43 +0000
Newsgroups gmane.comp.gcc.help
Message-ID <[email protected]>
Hello


Is there a way to make these "notes" appear as warnings? That can then be upgraded to errors by -Werror

https://godbolt.org/z/4ae71rfj8

#include <string>
#include <cstdio>

typedef struct a
{
    int a;
    int b;
    char buf[10];
} a_t;

int main()
{
    a_t * i;
    i = nullptr;
    printf("%s\n", i->buf);
}



<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]
   18 |     printf("%s\n", i->buf);
      |     ~~~~~~^~~~~~~~~~~~~~~~
cc1plus: note: source object is likely at address zero
ASM generation compiler returned: 0
<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]
   18 |     printf("%s\n", i->buf);
      |     ~~~~~~^~~~~~~~~~~~~~~~
cc1plus: note: source object is likely at address zero
Execution build compiler returned: 0
Program returned: 139