wait3() bug

When compiling this program:

#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>

void foo(void) {
int status;
int pid, options;
struct rusage ru;
pid = wait3(&status, options, &ru);
}

clang reports:
wait3.c:10:15: error: incompatible type passing ‘int *’, expected ‘__WAIT_STATUS’
pid = wait3(&status, options, &ru);
^~~~~~~
1 diagnostic generated.

But gcc works fine.

This is the relevant code after preprocessing:

1 “/usr/include/bits/waitflags.h” 1 3 4

39 “/usr/include/sys/wait.h” 2 3 4

63 “/usr/include/sys/wait.h”

typedef union
{
union wait *__uptr;
int *__iptr;
} __WAIT_STATUS attribute ((transparent_union));

extern __pid_t wait3 (__WAIT_STATUS __stat_loc, int __options,
struct rusage * __usage) attribute ((nothrow));

And in the man page for wait3:

SYNOPSIS
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>

pid_t wait3(int *status, int options,
struct rusage *rusage);

How should we deal with such case?

transparent_union is current unimplemented.

-Eli

Thanks.

I didn’t notice the attribute ((transparent_union)).