[Bug c++/118458] New: No mechanism to disable all warnings locally (supported by Clang with diagnostic ignored "-Weverything")
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118458 Bug ID: 118458 Summary: No mechanism to disable all warnings locally (supported by Clang with diagnostic ignored "-Weverything") Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: stephenberry.developer at gmail dot com Target Milestone: --- With Clang it is possible to locally disable all warnings where they may be invalid or unhelpful: #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" // ... Code here for which we want to disable warnings #pragma clang diagnostic pop It is extremely helpful to be able to enable -Wall and -Werror on codebases, to ensure all warnings are handled by developers. However, there are some corner cases where the compiler may issue a warning that the developer cannot fix or for which there is no issue and the code is 100% standard compliant. I develop the C++ Glaze library and this issue prevents users from enabling -Werror, because I have no means of disabling some warnings with GCC. On Clang, myself and other developers can use -Werror, because it is possible to disable warnings where they are rightly ignored. It would be wonderful for GCC to add support for: diagnostic ignored "-Weverything" Thanks for your consideration, Stephen
[Bug c++/118458] No mechanism to disable all warnings locally (supported by Clang with diagnostic ignored "-Weverything")
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118458 --- Comment #6 from Stephen Berry --- Here is my primary case for disabling the waring: https://github.com/stephenberry/glaze/blob/main/include/glaze/reflection/to_tuple.hpp Line 38 This is for the any_t operator T: template requires(!std::same_as && !std::same_as) [[maybe_unused]] constexpr operator T() const; This code is used for compile time reflection. It enables counting the number of members in a struct at compile time. So, there is no use of this function call at runtime. The fact that it is never defined is critical because it allows custom types to be counted.
[Bug c++/118458] No mechanism to disable all warnings locally (supported by Clang with diagnostic ignored "-Weverything")
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118458 --- Comment #7 from Stephen Berry --- I should clarify that GCC doesn't appear to emit this warning after GCC13. So, in this case I was looking for a solution for older versions of GCC. This request was written generically, so that the issue could be avoided in the future for warnings that developers want to disable.
[Bug c++/118458] No mechanism to disable all warnings locally (supported by Clang with diagnostic ignored "-Weverything")
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118458 --- Comment #4 from Stephen Berry --- One particular warning I'm trying to silence right now is: `used but never defined`. I now see that there is an open issue to disable this particular warning here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66918 It would be useful to be able to disable all warnings as we wait for specific options to be added to disable warnings.
[Bug c++/118458] No mechanism to disable all warnings locally (supported by Clang with diagnostic ignored "-Weverything")
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118458 --- Comment #10 from Stephen Berry --- I definitely get warnings in GCC12, but from more complex constexpr code than your simple example. Example output: error: inline function ‘constexpr glz::detail::any_t::operator T() const [with T = double]’ used but never defined [-Werror] But, I didn't open this issue with the intent to fix these incorrect warnings, because they seem already to be fixed in later GCC. Instead, I'm just using this as an example of how I have been unable to properly setup pipelines that test for warnings in GCC because there is no way to disable some warnings. This is also true when encountering third party code that cannot be edited.