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

    <tr>
        <th>Summary</th>
        <td>
            [clang] discrepancy between different version of constexpr bit_cast
        </td>
    </tr>

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

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

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

<pre>
    Using trunk (or tag 19.1), this code compiles fine and runs as expected : 

```
static constexpr int bit_cast_float_to_int(float value) {
 union {
        float f;
        int i;
    } u;
    u.f = value;
    return u.i;
}

int main() {
    return bit_cast_float_to_int(1.0F);
}
```

yielding : 

```
main:
  movl $1065353216, %eax
 retq
```

while this one

```

static constexpr int bit_cast_float_to_int(float value) {
    union {
        float f;
 int i;
    } u;
    u.f = value;
    return u.i;
}

constexpr int zou = bit_cast_float_to_int(1.0F);

int main() {
    return zou;
}
```

does not because of errors : 

```
<source>:11:15: error: constexpr variable 'zou' must be initialized by a constant expression
   11 | constexpr int zou = bit_cast_float_to_int(1.0F);
      |               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:8:12: note: read of member 'i' of union with active member 'f' is not allowed in a constant expression
    8 |     return u.i;
      |            ^
<source>:11:21: note: in call to 'bit_cast_float_to_int(1.000000e+00)'
   11 | constexpr int zou = bit_cast_float_to_int(1.0F);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Compiler returned: 1
```

Link to godbolt : https://godbolt.org/z/xPWh7nMPs
options : -std=c++20 


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vkuv4yYU_jUnm6OJDMRxsvDi5uZmUbXSbNpZXmE4TuhgSAHnPhb97RW2Z5JM70tqB0U4YM7jO98HWMZo9o6ohnID5XYm-3Twof6Fvsg_aNZ4_VT_Ho3bYwq9-4rAVz5gkntk6zkDvgZ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