NagyDonat wrote: I'm reopening this discussion because I'm strongly convinced that `AllowCastToVoid` should default to `true`, even after reading the arguments against it.
@gamesh411 has closed this ticket with "It is just unfortunate that there is no convenient way to express this (prior to C++26, which is very far from becoming widely adopted).", but in fact there is a convenient, non-ambiguous and widespread way to suppress unused value warnings, and that is the `(void) value` cast expression. The `(void)value` suppression is widely understood and used, for example it appears more than 500 times in the Clang codebase under `clang/lib` (and 10.000+ times in the artificial code fragments under `clang/test`). A `(void) value` expression clearly intends to mark that value as used (there are no alternative reasons for writing this) – so I think it is unacceptable that clang-tidy` "plays dumb" and pretends to not understand (unless the user jumps through some hoops). > We don't actively discourage users from using `(void)` - we simply provide an > option to allow it. > > The design is as strict as possible by default, so that users don't > accidentally overlook this option. This is a bad approach: if we applied this everywhere, we would end up with defaulting clang to `-Weverything` so that the users "don't accidentally overlook" some of our warnings. > For users who are configuring this check, modifying the configuration to > allow `(void)` should be easy. It is easy _for you_ who already know that this option exists. When a new user tries `clang-tidy` and sees these overzealous opinionated warnings, they won't hope that there is a config option that changes this. Faced with this annoyance, many users will just disable the check – or even conclude that "clang-tidy is dumb" and discard it altogether (especially if they also see other unwanted results). @zwuis I understand that you personally dislike `(void) value` casts, but I didn't see anyone else who shares this opinion. @zeyi2 @EugeneZelenko @localspook @unterumarmung @vbvictor What do you think about this situation? https://github.com/llvm/llvm-project/pull/200173 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
