https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80959
Bug ID: 80959 Summary: -Wreturn-type "control reaches end of non-void function" false positive with -fsanitize=address Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: simon.marchi at polymtl dot ca Target Milestone: --- Created attachment 41458 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41458&action=edit Reproducer I stumbled on this while building the binutils-gdb repo with -fsanitize=address with gcc 7.1.0 and reproduced it with gcc master from today. It doesn't happen with my distro compiler (5.4.0-6ubuntu1~16.04.4). gcc reports that the control can reach the end of the function, but I think it's not the case. This is the smallest reproducer I managed to find. Note that the problem disappears if you enable optimizations (-O > 0) or remove -fsanitize=address. Compile the attached file with: $ /opt/gcc/git/bin/gcc -Wreturn-type -Werror -O0 -fsanitize=address -c test.c test.c: In function 'foo': test.c:23:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1: all warnings being treated as errors