https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116386

            Bug ID: 116386
           Summary: false-positive -Werror=return-type when compiling with
                    -fsanitize=thread
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pierrick.bouvier at posteo dot net
  Target Milestone: ---

$ cat file.c
#include <assert.h>
int tab[10];
int f()
{
    for (int i = 0; i < 10; ++i) 
    {
        if (tab[i]) {
            return 0;
        }
    }
    assert(0);
}

$ gcc -c -Wall -Werror file.c
# no warning
$ gcc -c -Wall -Werror file.c -fsanitize=thread 
file.c: In function ‘f’:
file.c:12:1: error: control reaches end of non-void function
[-Werror=return-type]

It seems like assert(0) is ignored during control flow analysis when compiling
with thread sanitizer.

Found on gcc 12.2.0 (debian stable), and still present on gcc 14.2.0 (debian
unstable).

Reply via email to