[cfe-dev] wait3() bug

Zhongxing Xu mymlreader at gmail.com
Wed Jul 23 22:19:43 PDT 2008


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080724/4bb17ecf/attachment.html>


More information about the cfe-dev mailing list