https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89885
Bug ID: 89885 Summary: --help=warning prints wrongly default values for options set via e.g. -Wall or -Wextra Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org Target Milestone: --- One example: $ gcc --help=warning -Wall -Wextra -Q | grep Wcatch-v -Wcatch-value -Wcatch-value=<0,3> 0 So it claims the value is 0. But: $ gcc -Wall -Wextra -Werror /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/warn/Wcatch-value-1.C /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/warn/Wcatch-value-1.C: In function ‘void foo()’: /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/warn/Wcatch-value-1.C:13:10: error: catching polymorphic type ‘struct B’ by value [-Werror=catch-value=] 13 | catch (B) {} // { dg-warning "catching polymorphic type" } | ^ Issues is that option common_handle_option_auto is called from: #0 common_handle_option_auto (opts=0x246be40 <global_options>, opts_set=0x246aea0 <global_options_set>, decoded=0x7fffffffd5e0, lang_mask=32, kind=0, loc=0, handlers=0x7fffffffd810, dc=0x246cf00 <global_diagnostic_context>) at options.c:16459 #1 0x00000000018466a4 in common_handle_option (opts=0x246be40 <global_options>, opts_set=0x246aea0 <global_options_set>, decoded=0x7fffffffd5e0, lang_mask=32, kind=0, loc=0, handlers=0x7fffffffd810, dc=0x246cf00 <global_diagnostic_context>, target_option_override_hook= 0x124b510 <ix86_option_override()>) at /home/marxin/Programming/gcc/gcc/opts.c:2807 #2 0x000000000184c5ef in handle_option (opts=0x246be40 <global_options>, opts_set=0x246aea0 <global_options_set>, decoded=0x7fffffffd5e0, lang_mask=32, kind=0, loc=0, handlers=0x7fffffffd810, generated_p=true, dc=0x246cf00 <global_diagnostic_context>) at /home/marxin/Programming/gcc/gcc/opts-common.c:1104 #3 0x000000000184c69f in handle_generated_option (opts=0x246be40 <global_options>, opts_set=0x246aea0 <global_options_set>, opt_index=594, arg=0x0, value=0, lang_mask=32, kind=0, loc=0, handlers=0x7fffffffd810, generated_p=true, dc=0x246cf00 <global_diagnostic_context>) at /home/marxin/Programming/gcc/gcc/opts-common.c:1130 But --help options are directly printed in: #0 print_filtered_help (include_flags=131072, exclude_flags=0, any_flags=0, columns=272, opts=0x21d70c0 <global_options>, lang_mask=16) at /home/marxin/Programming/gcc/gcc/opts.c:1303 #1 0x000000000162173e in print_specific_help (include_flags=131072, exclude_flags=0, any_flags=0, opts=0x21d70c0 <global_options>, lang_mask=16) at /home/marxin/Programming/gcc/gcc/opts.c:1683 #2 0x0000000001622af5 in common_handle_option (opts=0x21d70c0 <global_options>, opts_set=0x21d6120 <global_options_set>, decoded=0x21ef780, lang_mask=16, kind=0, loc=0, handlers=0x7fffffffd820, dc=0x21d8180 <global_diagnostic_context>, target_option_override_hook= 0x1032fc0 <ix86_option_override()>) at /home/marxin/Programming/gcc/gcc/opts.c:2244 Correct behavior would be to print --help late after all is set. Ideally in finish_options.