[lld] [lld] Remove const qualifier on symbolKind (NFC) (PR #94753)

Richard Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 11:58:57 PDT 2024


zygoloid wrote:

> @zygoloid : Is the `const` use UB? Even if no, should this specific use be discouraged?

The relevant rule was [changed for C++20](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1971r0.html); now `const` only fully disallows modification for complete objects, and `const` on data members doesn't actually mean the member is immutable any more.

Regardless I think it's best to avoid `const` on non-static data members in general (because it prevent assignment) and especially for ones that are actually modified -- it looks to me like this `memcpy` is effectively an assignment).

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


More information about the llvm-commits mailing list