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

--- Comment #1 from Rimvydas (RJ) <rimvydas.jas at gmail dot com> ---
The -fanalyzer does not seem to handle glibc __CONST_SOCKADDR_ARG definitions
with transparent_unions that are used under -D_GNU_SOURCE (__USE_GNU).

Minimal reduced testcase:
$ cat test_sockaddr.c
struct sockaddr; struct sockaddr_x25;

#if defined __cplusplus || !defined _GNU_SOURCE
# define __CONST_SOCKADDR_ARG   const struct sockaddr *
#else
typedef union {
  const struct sockaddr * __sockaddr__; /* ... */
  const struct sockaddr_x25 * __sockaddr_x25__;
  } __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));
#endif

extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, unsigned int __len);
extern void __analyzer_eval (int);

void test_null_connect (int fd)
{ __analyzer_eval (connect (fd, 0, 0) == -1); } /* { dg-warning "TRUE" } */

$ ./gcc/xgcc -Bgcc/ -fdiagnostics-plain-output -fanalyzer -c test_sockaddr.c
test_sockaddr.c: In function 'test_null_connect':
test_sockaddr.c:16:3: warning: TRUE
$ ./gcc/xgcc -Bgcc/ -fdiagnostics-plain-output -fanalyzer -c test_sockaddr.c
-D_GNU_SOURCE
test_sockaddr.c: In function 'test_null_connect':
test_sockaddr.c:16:3: warning: UNKNOWN

Reply via email to