<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/83752>83752</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            static_assert failed in system installed `libntirpc`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          silver-ymz
      </td>
    </tr>
</table>

<pre>
    The definition of struct `XDR` is different in `/usr/include/ntirpc/rpc/xdr.h` and `/usr/include/tirpc/rpc/xdr.h`. So the size check can't pass in system installed `libntirpc`.

System Info: `Intel(R) Xeon(R) Gold 6146 CPU @ 3.20GHz`, `Linux iaircag-Precision-7920-Tower 6.2.0-39-generic #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux`

<details>
<summary>Error Info</summary>

```
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1308:1: error: static_assert failed due to requirement 'sizeof(__sanitizer::__sanitizer_XDR) == sizeof(rpc_xdr)' ""
CHECK_TYPE_SIZE(XDR);
^~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1480:3: note: expanded from macro 'CHECK_TYPE_SIZE'
 COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                             ^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1309:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_op) == __builtin_offsetof(rpc_xdr, x_op)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_op);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                             ^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1310:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_ops) == __builtin_offsetof(rpc_xdr, x_ops)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                             ^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1311:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_public) == __builtin_offsetof(rpc_xdr, x_public)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_public);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                             ^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1312:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_private) == __builtin_offsetof(rpc_xdr, x_private)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_private);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                             ^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1313:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_base) == __builtin_offsetof(rpc_xdr, x_base)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_base);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                             ^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1314:1: error: static_assert failed due to requirement '__builtin_offsetof(__sanitizer::__sanitizer_XDR, x_handy) == __builtin_offsetof(rpc_xdr, x_handy)' ""
CHECK_SIZE_AND_OFFSET(XDR, x_handy);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1485:3: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:30: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                             ^ ~~~~
7 errors generated.
```
</details>

I try printing the detail size with following code

```cpp
template<size_t A, size_t B> struct TAssertEquality {
  static_assert(A==B, "Not equal");
  static constexpr bool _cResult = (A==B);
};
static constexpr bool _cIsEqual = 
  TAssertEquality<sizeof(__sanitizer_XDR), sizeof(XDR)>::_cResult;
```

Results:
```
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1309:3: error: static_assert failed due to requirement '48UL == 112UL' "Not equal"
  static_assert(A==B, "Not equal");
  ^ ~~~~
/home/yinmingzhuo/research/RPG2/bat-dump/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1313:3: note: in instantiation of template class 'TAssertEquality<48, 112>' requested here
  TAssertEquality<sizeof(__sanitizer_XDR), sizeof(XDR)>::_cResult;
  ^
```

Definition of `XDR` in `libntirpc`:
```
typedef struct rpc_xdr {
        const struct xdr_ops {
                /* get 4 unsigned bytes from underlying stream */
                bool (*x_getunit)(struct rpc_xdr *, uint32_t *);
 /* put 4 unsigned bytes to underlying stream */
 bool (*x_putunit)(struct rpc_xdr *, const uint32_t);
                /* get some bytes from " */
                bool (*x_getbytes)(struct rpc_xdr *, char *, u_int);
                /* put some bytes to " */
 bool (*x_putbytes)(struct rpc_xdr *, const char *, u_int);
 /* returns bytes off from beginning */
                u_int (*x_getpostn)(struct rpc_xdr *);
                /* lets you reposition the stream */
                bool (*x_setpostn)(struct rpc_xdr *, u_int);
                /* free private resources of this xdr_stream */
                void (*x_destroy)(struct rpc_xdr *);
 bool (*x_control)(struct rpc_xdr *, int, void *);
                /* new vector and refcounted interfaces */
                bool (*x_getbufs)(struct rpc_xdr *, xdr_uio *, u_int);
                bool (*x_putbufs)(struct rpc_xdr *, xdr_uio *, u_int);
                /* Force a new buffer to start (or fail) */
                bool (*x_newbuf)(struct rpc_xdr *);
                /* Return the count of buffers in the vector from pos */
                int (*x_iovcount)(struct rpc_xdr *, u_int, u_int);
                /* Fill xdr_vio with buffers from pos */
 bool (*x_fillbufs)(struct rpc_xdr *, u_int , xdr_vio *, u_int);
 /* Allocate bufs for headers and trailers and insert into vio */
                bool (*x_allochdrs)(struct rpc_xdr *, u_int , xdr_vio *, int);
        } *x_ops;
        void *x_public; /* users' data */
        void *x_private; /* pointer to private data */
        void *x_lib[2]; /* RPC library private */
        uint8_t *x_data;  /* private used for position inline */
        void *x_base;  /* private used for position info */
        struct xdr_vio x_v; /* private buffer vector */
        u_int x_handy; /* extra private word */
        u_int x_flags; /* shared flags */
        enum xdr_op x_op;  /* operation; fast additional param */
} XDR;
```

Definition of `XDR` in `libtirpc`:
```
typedef struct __rpc_xdr {
        enum xdr_op x_op;           /* operation; fast additional param */
        const struct xdr_ops {
                /* get a long from underlying stream */
                bool_t  (*x_getlong)(struct __rpc_xdr *, long *);
 /* put a long to " */
                bool_t (*x_putlong)(struct __rpc_xdr *, const long *);
                /* get some bytes from " */
                bool_t  (*x_getbytes)(struct __rpc_xdr *, char *, u_int);
                /* put some bytes to " */
                bool_t  (*x_putbytes)(struct __rpc_xdr *, const char *, u_int);
                /* returns bytes off from beginning */
 u_int   (*x_getpostn)(struct __rpc_xdr *);
                /* lets you reposition the stream */
                bool_t  (*x_setpostn)(struct __rpc_xdr *, u_int);
                /* buf quick ptr to buffered data */
                int32_t *(*x_inline)(struct __rpc_xdr *, u_int);
 /* free privates of this xdr_stream */
                void (*x_destroy)(struct __rpc_xdr *);
                bool_t (*x_control)(struct __rpc_xdr *, int, void *);
        } *x_ops;
 char *          x_public;       /* users' data */
        void * x_private;      /* pointer to private data */
        char * x_base;         /* private used for position info */
        u_int x_handy;        /* extra private word */
} XDR;
```

Definition of `__sanitizer_XDR` in `compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h`
```
struct __sanitizer_XDR {
  int x_op;
  void *x_ops;
  uptr x_public;
 uptr x_private;
  uptr x_base;
  unsigned x_handy;
};
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW0tv4zgS_jXMhYghU34ecnAcuyfYTk-QBzCzF4GWSjZ3KFJDUondh_ntC1IPy7biWOnuTRaIEfhBqYrFr6o-FkWGas2WAuAC9S9R_-qMZmYl1YVm_AnU-Sb5fraQ0ebiYQU4gpgJZpgUWMZYG5WFBqOB98fVHRp4mGkcsTgGBcJgJuwVROaZVojMmQh5FgEic2GYSkNE5vn7OlKdlZWmInpBolmgg-8lNivAmn0HHK4g_AuHVCAyNDilWlsL9EYbSDAT2lDOwXXA2aIwYeB1kHeFvEn-fp_ffC1iifyJvfVaGOCIjO4QGeM_QIry-xfJIzzo9gZ4evuIUc_Dfod4X3777gYwtbJfmcjWmFGmQro8v1UQMs2kOB-OiXf-IJ9B4UGHdLxzf3y-BAGKhRgRv-f9Q0jH63W654-LTJgM39_c4tu72ezm9iG4-vPb5OZ6ih9WGf4mn3B3gLse8id9H_kTr4cfH6aY4PVoEAx6ex9fvj0iMndWWSNr40b-NAJDGdfIn1VNOksSqjbIn82UkqqAZYrIfHtlR8vAK_7yn2S-kon13oaJhInl91UmrQ9BA1XhCpH53e0Xgsh8Qc15lCUpIvNQJinjoM6VQWTO2cL2Rm3EfQcVhDJJrAtqTSmnJpYqCThLmNFBKjVbd8I0Rf6k63sj-2F9CXYI9os21LAwoFqDMjimzAZFlAE2Eiv4O2MKEhu9iAxtWMkYkVEQVB0if4L8Sa0hsKFPxhj5V8i_wpWMSsNgHSlExogMMSLE_jlgpr_Npv8KHv68nQX31_-eITLKVSD_skCuP_vn8PX-qK4smL2RDTcbbVhIAw7bdUpFBBGOlUxwQkMlLXwH4xzmQ8DT329ur7_O7gJ3ByKjJqADRHxEfCveBG_Rbv9ypc2gnfb6X0LLhAElKA8iiLWD1O9ZNH3vFEj3kBuWlvuOmOEQ2lRBZPHbCfuqfVoGZgXjsRfqz_DHiMQqv8c_kt9BsMgYN0wEMo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