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

    <tr>
        <th>Summary</th>
        <td>
            Clang behaves somewhat weirdly with pointer to member field cast inside a class not completed and inheritance
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          Rush10233
      </td>
    </tr>
</table>

<pre>
    The following code compiles normally in clang:

```c++
struct A { int i; };
struct B:A { int j; };
struct C:B { int k; static_assert((int(B::*))&C::k, ""); };
```

But it's rejected by gcc which complains that `&C::k` should not be constant before the class `C` is completed:

```c++
<source>:3:35: error: non-constant condition for static assertion
    3 | struct C:B { int k; static_assert((int(B::*))&C::k, ""); };
      | ^~~~~~~~~~~~~~~~
<source>:3:35: error: '&C::k' is not a constant expression when the class 'C' is still incomplete
Compiler returned: 1
```
Note that the `static_assert` expression requires its first parameter to be compile-time constant. It seems at least one of the compilers does the wrong thing. Since the standard of class member variable pointer assignment looks a little complex, we currently cannot judge for certain which behavior is reasonable. We hope that can be further identified.

[https://godbolt.org/z/MWeYx7sYq](https://godbolt.org/z/MWeYx7sYq)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8lM1u4zYQx5-GvgxiyJRtWQcdbGcN9NAe2gKLPRUUObYmoUgvZxQnPfTZC0rOhxctkNMKTEwQw_n4zZ9jmOkUEBu12qnV_cwM0sXU_D5wtyh0Wc7a6F6aPzuEY_Q-XiicwEaHYGN_Jo8MIabeeP8CFMB6E06q3KriXhWv_9fFtKzSu7zGU5Y0WIEtqGoHFARIlTtQ1b0qby12qty-Wz38j9Veldvdm9VjtmIxQvYvw4xJlN4ovaGQN9ljXnqrdD2u9X46elR6D0rrcdU_hnor5GN1u0GAROmKIeEDWkEH7QucrIVLR7YbOXlDgUE6I5Cvf4i3LoC7OHgH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