https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90264
Roman Zhuykov <zhroma at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Last reconfirmed| |2019-04-29 Resolution|INVALID |--- Summary|[9/10 Regression] |[9/10 Regression] |-Wnull-dereference false |-Wnull-dereference QoI |positive after r270574 |issue Ever confirmed|0 |1 --- Comment #4 from Roman Zhuykov <zhroma at gcc dot gnu.org> --- Let me perhaps explain better. Function asprintf should set *s to point allocated memory and return non-negative amount of printed chars. When allocation fails it will return -1. So, there are really no issue in the original code, but compiler isn’t clever enough to know how asprintf works. Gcc 8 doesn’t warn, thats why I’ve created this bugreport as false-positive. So, here trunk gives a warning: https://godbolt.org/z/-o6UMv If we decide that warning is correct, we must also warn same code, when -1 bailout removed: https://godbolt.org/z/ayb9pS Than we have a false negative and it is *not* a “9 Regression”, but we have to fix it. I also want to note, that when -2 bail out is removed from both examples, 8.3 and trunk give a warning. There is a separate issue with gcc 8.3 here, it warns two times. <source>: In function 'cn_sequence': <source>:11:8: warning: potential null pointer dereference [-Wnull-dereference] *out = '\0'; ~~~~~^~~~~~ <source>:11:8: warning: potential null pointer dereference [-Wnull-dereference] Compiler returned: 0 But I haven’t checked recent 8-branch, maybe that was fixed and backported after 8.3.