thakis added a comment. In D131704#3717950 <https://reviews.llvm.org/D131704#3717950>, @shafik wrote:
> In D131704#3717774 <https://reviews.llvm.org/D131704#3717774>, @akhuang wrote: > >> We're seeing this warning in code with global constants, e.g. >> >> const Enum x = static_cast<Enum>(-1); >> >> is this intended? > > This is constant initialization, so this is indeed expected. > > Depending on your situation you can fix this by using a fixed underlying type > e.g. : `enum A : int` or by making it a scoped enum `enum class A` or by > extending the enumerators themselves to include the value you are using. > > If this not your code you can also turn the error into a warning using > `-Wno-error=enum-constexpr-conversion` Another question about this. The diag name and all the wording so far was about "constexpr". The expression Amy pasted is constant initialization, but _not_ constexpr. Is this really intentional? This is quite an increase in scope for the diag, if so. we did a full cleanup for the original diag, but after the recent tweaks it fires in many many more places. Can we put this under a different warning flag for non-constexpr cases if this is really intentional? I'm assuming the non-constexpr case won't become an unconditional error later? It probably also shouldn't be mapped to an error? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131704/new/ https://reviews.llvm.org/D131704 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits