Inconsistencies in docs for -Wall and -Wextra warnings
Sandra Loosemore
sloosemore@baylibre.com
Tue Sep 9 14:55:30 GMT 2025
On 9/9/25 02:56, Jonathan Wakely wrote:
> I was going to correct the fact that this list of options enabled by
> -Wextra doesn't mention that -Wunterminated-string-initialization is
> only valid for C and ObjC:
>
> @gccoptlist{-Wabsolute-value @r{(only for C/ObjC)}
> -Walloc-size
> -Wcalloc-transposed-args
> -Wcast-function-type
> -Wclobbered
> -Wdangling-reference @r{(C++ only)}
> -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
> -Wempty-body
> -Wenum-conversion @r{(only for C/ObjC)}
> -Wexpansion-to-defined
> -Wignored-qualifiers @r{(only for C/C++)}
> -Wimplicit-fallthrough=3
> -Wmaybe-uninitialized
> -Wmissing-field-initializers
> -Wmissing-parameter-name @r{(C/ObjC only)}
> -Wmissing-parameter-type @r{(C/ObjC only)}
> -Wold-style-declaration @r{(C/ObjC only)}
> -Woverride-init @r{(C/ObjC only)}
> -Wredundant-move @r{(C++ and Objective-C++ only)}
> -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
> -Wsign-compare @r{(C++ and Objective-C++ only)}
> -Wsized-deallocation @r{(C++ and Objective-C++ only)}
> -Wstring-compare
> -Wtype-limits
> -Wuninitialized
> -Wunterminated-string-initialization
> -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
> -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or}
> @option{-Wall}@r{)}}
>
> But then I noticed that the "only" parentheticals are wildly
> inconsistent. We have:
>
> only for C/ObjC
> C++ and Objective-C++ only
> C/ObjC only
>
> It would be good if we used the same form every time. In the
> documentation for individual options we always use the (X and Y only)
> form, and the list of options for -Wall _mostly_ uses that form (with
> a few exceptions that use the "only for C/ObjC" form).
>
> I can see an argument for keeping those lists a bit more concise (so
> "only for X/Y" rather than "X and Y only") but we should pick a form
> and be locally consistent.
>
> Should I change those to all use the full "X and Y only" form that is
> used on docs for the individual options, and always spell out
> Objective-C in full? i.e. replace all "only for X/Y" and "X/Y only"
> cases?
Good catch on this. I think the preferred form ought to be the one that
is already used elsewhere, and we should prefer "Objective-C" to "ObjC".
But, I have one concern: the @gccoptlist shouldn't overflow the right
margin in the PDF document, and if any of the lines become long enough
to do that, something needs to be done to fix it, either using
abbreviations or changing to some other Texinfo markup for the table
(and presumably others like it in the manual).
-Sandra
More information about the Gcc
mailing list