[libc++] Void-cast runtime-unused variables.
Also, remove unused names in exception handlers, remove an unused array, move a conditionally-used array, and remove unused argc/argv.
Fixes MSVC "warning C4101: unreferenced local variable".
Paths
| Differential D19625
[libc++] Void-cast runtime-unused variables. ClosedPublic Authored by STL_MSFT on Apr 27 2016, 2:34 PM.
Details
Summary [libc++] Void-cast runtime-unused variables. Also, remove unused names in exception handlers, remove an unused array, move a conditionally-used array, and remove unused argc/argv. Fixes MSVC "warning C4101: unreferenced local variable".
Diff Detail Event TimelineSTL_MSFT updated this object. Comment Actions Are there any issues with these changes? I tried to follow the existing practice for void-casting, including the comment (although the comments varied). EricWF edited edge metadata. Comment ActionsOne inline change requested.
This revision now requires changes to proceed.Apr 28 2016, 6:31 PM STL_MSFT updated this object. STL_MSFT edited edge metadata. Comment ActionsThis moves "str" as requested. It also adds void casts to another file, and removes an unused argc/argv pair. Comment Actions I'm not sure why we'd want to compile the test suite with -Wunused-variable Comment Actions What I'm doing is running libcxx's tests against MSVC's compiler and libraries. I could aggressively suppress warnings (and indeed I'm doing that for the noisiest, lowest-value warnings), but instead I'm building the tests with /W4 (our highest supported level). It is indeed somewhat annoying to make tests warning-free, although it does find real issues occasionally (e.g. the broken assert that I reported first). The real value is verifying that the headers are warning-free, which has the potential to catch issues in the product code. This is possibly a difference in philosophy between VC's STL and libc++, because I believe libc++ uses the "system header" behavior to avoid all warnings from system headers.
Comment Actions [David Blaikie]
Yeah, but it still has the potential to detect mistakes (e.g. typos, or code you intended to write but forgot about). I figured I'd submit a patch, since there weren't actually that many occurrences, and they were all easy to silence in a targeted manner, following existing conventions.
For the time being, I've decided that fixing signed/unsigned mismatch and similar warnings is too much work, so I'm globally suppressing them. (There were hundreds.)
When my work is finished (currently 3132 tests are passing out of 4541), I expect that we'll start running libcxx's tests in our automation, which will detect regressions rapidly and reliably. For this particular warning, the suppression mechanism is super simple and easy to maintain (if you don't mention a variable at runtime, have the void cast).
Yes. Gotta instantiate stuff. There are two main scenarios in which you'd want to see warnings in the STL. The first is when the STL itself is doing something bad. The second is when user code causes the STL to do something bad. For example, giving less<int32_t> to an STL algorithm with an int64_t range. That'll truncate, but the truncation happens within the algorithm. (We do have "include all headers" and "include each header alone" tests for other reasons.) STL Comment Actions Our test harness has a switch to enable warnings. I would be happy to set up a bot in that configuration. It would probably be easier than setting up one that uses MSVC. Thanks again for cleaning these warnings up. I've been meaning to get to it *eventually*. Comment Actions No problem! With these changes, my test runs are currently clean wrt "warning C4100: unreferenced formal parameter" and "warning C4101: unreferenced local variable", but note that (1) Clang may emit unused-variable warnings in somewhat different situations, and (2) I've still got 25% of the tests failing to compile, which may be hiding further warnings. This revision is now accepted and ready to land.May 2 2016, 12:18 PM Comment Actions r268284.
I'm hoping Clang is pretty similar. I guess we will see. I'm going to hold off setting up a bot for a while still.
Revision Contents
Diff 55324 test/std/depr/depr.c.headers/setjmp_h.pass.cpp
test/std/depr/depr.c.headers/stdio_h.pass.cpp
test/std/input.output/file.streams/c.files/cstdio.pass.cpp
test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
test/std/language.support/support.exception/propagation/current_exception.pass.cpp
test/std/language.support/support.runtime/csetjmp.pass.cpp
test/std/language.support/support.runtime/ctime.pass.cpp
test/std/localization/c.locales/clocale.pass.cpp
test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
test/std/numerics/rand/rand.device/eval.pass.cpp
test/std/re/re.alg/re.alg.search/grep.pass.cpp
test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp
test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp
test/std/utilities/time/date.time/ctime.pass.cpp
test/std/utilities/utility/forward/forward.pass.cpp
|
Isn't this unused as well on non-apple platforms?