<div dir="ltr">Hi all,<div><br></div><div>I find clang's unused variable warning very useful to keep the code from accumulating garbage over time. For built-in types it works great, but I've noticed that for user-defined types it often misses unused variables. The current logic for user-defined types is to warn on unused variable if 1) the type has a trivial destructor 2) the constructor is either elided or trivial, or the type is marked with warn_unused attribute [1].</div>
<div>Does anyone object to extending 2) to allow constexpr constructors? The reasoning is that constexpr constructors are not supposed to have any side-effects.</div><div>What about a check that constructor does not have side-effects, even if it's not marked as constexpr? This can start by using the same code as the one for constexpr checking. Is this the right thing in the compiler, or should this go into clang-tidy?<br>
</div><div><br></div><div>[1] <a href="http://clang.llvm.org/doxygen/SemaDecl_8cpp_source.html#l01426">http://clang.llvm.org/doxygen/SemaDecl_8cpp_source.html#l01426</a><br></div><div><br></div><div>Thanks,</div><div>Eugene</div>
</div>