[clang] [clang] Check constexpr int->enum conversions consistently. (PR #143034)

Tom Stellard via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 4 07:13:33 PDT 2025


tstellar wrote:

I'm seeing a regression from this commit too with this reproducer which gcc accepts.  Is clang correct to give an error here?

```
template <class _Tp> using decay_t = _Tp;
namespace base::internal {
template <typename Enum> struct EnumSizeTraits {
  static constexpr Enum Count() { return Enum(Enum::kMaxValue + 1); }
};
} // namespace base::internal
enum { kUnknown = 3, kMaxValue = kUnknown };
void SandboxLinuxReportLandlockStatus() {
  static_assert(
      base::internal::EnumSizeTraits<decay_t<decltype(kUnknown)>>::Count());
}

```



https://github.com/llvm/llvm-project/pull/143034


More information about the cfe-commits mailing list