[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] Stifling "unused" warnings
From: |
Greg Chicares |
Subject: |
[lmi] Stifling "unused" warnings |
Date: |
Tue, 26 Oct 2021 21:11:39 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
I can't remember why I wrote both these function templates:
stifle_warning_for_unused_variable()
stifle_warning_for_unused_value()
when it seems that either should suffice. I've searched the
mailing list and the commit history, but found no rationale.
The patch below [0] swaps the implementations. Rerunning
'nychthemeral_test.sh' with that patch finds no problem.
Therefore, I think we can and should merge these together.
Of the two, I prefer the one whose implementation is "{}",
which is identical to the proposal here:
https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/
except that Herb would omit "inline" as being unnecessary,
while I would retain it as being harmless and suggestive.
Comments?
---------
[0] "The patch below":
diff --git a/miscellany.hpp b/miscellany.hpp
index 5fd12eaf6..95a9bf8a3 100644
--- a/miscellany.hpp
+++ b/miscellany.hpp
@@ -296,8 +296,10 @@ inline unsigned char lmi_toupper(unsigned char c)
/// conditional-inclusion [16.1] block.
template<typename T>
-inline void stifle_warning_for_unused_variable(T const&)
-{}
+inline void stifle_warning_for_unused_variable(T const& t)
+{
+ (void)&t;
+}
/// DWISOTT
///
@@ -309,9 +311,7 @@ inline void stifle_warning_for_unused_variable(T const&)
/// for volatile types.
template<typename T>
-inline void stifle_warning_for_unused_value(T const& t)
-{
- (void)&t;
-}
+inline void stifle_warning_for_unused_value(T const&)
+{}
#endif // miscellany_hpp
- [lmi] Stifling "unused" warnings,
Greg Chicares <=
- Re: [lmi] Stifling "unused" warnings, Vadim Zeitlin, 2021/10/26
- Message not available
- Re: [lmi] Stifling "unused" warnings, Greg Chicares, 2021/10/26
- Re: [lmi] Stifling "unused" warnings, Vadim Zeitlin, 2021/10/27
- Message not available
- Re: [lmi] Stifling "unused" warnings, Greg Chicares, 2021/10/27
- Re: [lmi] Stifling "unused" warnings, Vadim Zeitlin, 2021/10/27
- Message not available
- Re: [lmi] Stifling "unused" warnings, Greg Chicares, 2021/10/27
- Re: [lmi] Stifling "unused" warnings, Vadim Zeitlin, 2021/10/27
- Message not available
- Re: [lmi] Stifling "unused" warnings, Greg Chicares, 2021/10/28
- Re: [lmi] Stifling "unused" warnings, Vadim Zeitlin, 2021/10/28