lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Stifling "unused" warnings


From: Vadim Zeitlin
Subject: Re: [lmi] Stifling "unused" warnings
Date: Tue, 26 Oct 2021 23:26:48 +0200

On Tue, 26 Oct 2021 21:11:39 +0000 Greg Chicares <gchicares@sbcglobal.net> 
wrote:

GC> I can't remember why I wrote both these function templates:
GC>   stifle_warning_for_unused_variable()
GC>   stifle_warning_for_unused_value()
GC> when it seems that either should suffice. I've searched the
GC> mailing list and the commit history, but found no rationale.

 I'm almost certain that we discussed this before, but you must have found
these discussions in the list archives. AFAIR I didn't see any reason to
have the 2 basically identical functions neither, but I wanted one of them
to take a non-const reference to allow using it with uninitialized
variables too, without triggering -Wuninitialized-const-reference from
clang.

 I believe I also thought we should make these functions constexpr, but I
don't remember why did I think it was preferable any more. OTOH I don't see
any drawbacks from it neither, so, I guess, why not?

GC> Therefore, I think we can and should merge these together.

 No objections from me.

GC> Of the two, I prefer the one whose implementation is "{}",

 Me too.

GC> which is identical to the proposal here:
GC>   https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/
GC> except that Herb would omit "inline" as being unnecessary,
GC> while I would retain it as being harmless and suggestive.

 I would remove "inline" too, but I don't feel strongly enough about it to
argue. If we do make the function constexpr, we should definitely remove
it, however, as it would be redundant as "constexpr" always implies
"inline" anyhow.

GC> Comments?

 The only other thing besides constexpr that I can think of is that I'd
prefer if we left stifle_warning_for_unused_value() and removed the other
one because this would make writing

        stifle_warning_for_unused_value(std::min(extreme, value));

instead of the current

        currency volatile z = std::min(extreme, value);
        stifle_warning_for_unused_variable(z);

natural, unlike using stifle_warning_for_unused_variable(), which wouldn't
read well, even if it did exactly the same thing.

 Thanks for cleaning this up!
VZ

Attachment: pgplSdX2WIlwA.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]