[libcxx-commits] [libcxx] [libc++] Diagnose unused variables of container types (PR #203084)

Yuxuan Chen via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 24 09:53:41 PDT 2026


yuxuanchen1997 wrote:

> > Hiding this behind a macro and having a way to opt out of the macro for at least one release has a very low cost, significantly simplifies the adoption in large code bases, and makes this patch uncontroversial. I think we should do it.
> 
> I think @philnik777 had a good point about thinking of the long-term design we want to end up with. Do we want libc++ to be configurable such that users can opt out of non-standards mandated functionality intended to help catch bugs? e.g., do we want users to have a way to opt out of nodiscard warnings, deprecation warnings, etc which are not mandated by the standard as a general feature of libc++? (We obviously want people to leave that kind of stuff enabled, but having an escape hatch for diagnostics is pretty typical for diagnostic behavior in the compiler so it stands to reason the library will have similar needs.)

I am fine with it not being a macro. I suggested one because that's one possible approach I can think of. As long as we are aligned that opting out of new warnings is a desirable feature for vendors, I am fine with any solution. 

I do see the value of these added warnings and would like to enable them whenever possible. The attached PR to clean unused container up for LLVM is already making the codebase better and more performant. However, the reality is that we need to spend substantial time to get the codebase ready for new warnings. And such codebase may contain third-party/OSS code that we don't easily control.

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


More information about the libcxx-commits mailing list