text: lebedev.ri added a comment. I'm waiting for @mclow.lists to have the final say re this differential.
  In, @Quuxplusone wrote: > In, @lebedev.ri wrote: > > > gcc does not silence the warning produced by > > these attributes via `(void)` cast, unless it's `[[nodiscard]]` attribute > > :/ > > [...] So until they fix that (they will fix that right? :)), > > we can only support `_LIBCPP_FORCE_NODISCARD` for clang compilers. > > > The GCC warn_unused_result issue is > and also > . I would certainly love > for them to fix it, but the sentiment expressed in those bug reports is "no! > never! we love being broken!". :/ > I re-suggest my idea that perhaps libc++ should respect the user's choice to > pass `-D_LIBCPP_NODISCARD=__attribute__((warn_unused_result))` on the GCC > command line. This would make your patch only one line longer than it is > right now... So roughly: // NOTE: Do not use [[nodiscard]] in pre-C++17 mode // to avoid -Wc++17-extensions warning. // And we can't use GCC's [[gnu::warn_unused_result]] and // __attribute__((warn_unused_result)), // because GCC does not silence them via (void) cast. #if !defined(_LIBCPP_NODISCARD) # if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 # define _LIBCPP_NODISCARD [[nodiscard]] # elif __has_cpp_attribute(clang::warn_unused_result) # define _LIBCPP_NODISCARD [[clang::warn_unused_result]] # else # define _LIBCPP_NODISCARD # endif #endif ? Repository: rCXX libc++ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org