https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #27 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Steven Bosscher from comment #26)
> Maybe make something like "-Wno-unused-result=[pedantic|nodiscard]", make 
> strict the current semantics of the flag and nodiscard the C++17 semantics
> (and make that the default)?

I see two alternatives:

1) Keep nosdiscard and __wur semantics separated and use different flags for
them such as a new -Wdiscard which is enabled by default so that users can use
-Wno-discard to disable "nodiscard" attrib warnings. (Or should it be
-Wnodiscard and -Wno-nodiscard?).

This has the downside that users of existing libraries using __wur do not see
any benefit and this PR goes on.

2) Make __wur more strict than nodiscard only if some new flag
-Wstrict-unused-result is enabled (stricter warnings would print this flag and
users can use -Wno- version to disable it completely without disabling
nodiscard warnings).

This has the downside that users and library devs happy with the existing
behavior will have their default silently changed. The upside is that users can
decide on their own if they want the looser semantics by flipping a single
switch.

Option (2) is equivalent to what is proposed above. In that case
-Wstrict-unused-result will imply -Wunused-result (but not the other way
around) and the only question is whether  -Wstrict-unused-result or
-Wunused-result is enabled by default.


"pedantic" has a very precise meaning within GCC that is already quite
difficult to explain, let's not make it even more complex by overloading it.

Reply via email to