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

    <tr>
        <th>Summary</th>
        <td>
            Confusing error messages about non-literal types being used in constant expressions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++20,
            clang:frontend
      </td>
    </tr>

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

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

<pre>
    Consider this example code:
```c++
class Base {
public:
  virtual ~Base() {}
};
constexpr int test() {
  Base b;
  return 0;
}
```

`clang -std=c++20` complains:
```console
<source>:8:8: error: variable of non-literal type 'Base' cannot be defined in a constexpr function before C++2b
  Base b;
       ^
<source>:3:11: note: 'Base' is not literal because its destructor is not constexpr
  virtual ~Base() {}
          ^
1 error generated.
```

However, using `-std=c++2b` instead gives:
```console
<source>:7:15: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
constexpr int test() {
              ^
<source>:8:8: note: non-literal type 'Base' cannot be used in a constant expression
  Base b;
       ^
1 error generated.
```
See: https://godbolt.org/z/aEbYKxfjT


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlM-P6jYQx_8a5zICJQ4myyEHFhZV6rGVqh79Ywh-Mjby2HRfD_3bK4cAu69sxbOCgGE8fOf7GY0ksoNH7Jl4ZWJbyZwOIfZJSTQYY6WC-d5vgidrMEI6WAJ8l8eTQ9DBIGvXrN6yes2W9eXRjL-WZ4xqJ4ngVRIC66bYKStn9e0iwNnGlKWDf0oe4y-Mr8bsbjuV7rasvRYMnhK-nyJYnyAhpQ8Xpnrj36nbFYCIKUcP9S10L31VPX29BrWTfoAZJcPa7dQRL3mgw_HkpPX0oPPgKTicou2GQo4aWfvG2vXL9AKMMcTy4SyjlcohhD344GfOJozSQfp-QmC8u5jRgZbehwQKweDeejRgPUi4G7HPXicbPCjch4iwmeSqL_0YDxNvD5W2rF03TVHoQyp8P4qxVKJw1apQy0wINhEYpBSzTiFes24SnwUNt3MT11wMgwE9RpnQzP8H3C_hLzxjZHwDmawfgC3rHxiqwtAWXdLAYM_4kxy74o74BPIBCV9kwCkGkzXSlZb0CUoeEpUkJl5nf1h_ls6a2d0rsX1-0j-er3jeJu-K87lhy_Rp0j5rf3KynoT3G466DimdRhp8x_huCEYFl-YhDozv_mZ8J9_Un7--77_9_hF5ZfrWrNqVrLBvlt2iW4iad9WhF_hiFDeLhTIruVpJIZRolyhXolu8GKwr2_Oat3XDl81CdHU316tOdHIpdNOiXDZ7tqjxKK2bO3c-Fh2VJcrYL-u2aSonFToatybn9w3BOeObEikLhLXrfQw-oTflB7GtYl-KzVQeiC1qZynRvXyyyWHZtfvL9F7MOyKRHMoUqZDTf-gRKCzJV14PaFGVo-t_sNemQ1ZzHY6M74qC6W12iuEb6sT4buyWGN-NDf8bAAD__8hK1T0">