https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122710
Bug ID: 122710
Summary: -fhardened breaks --help=topic unless a file is passed
to cc
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: landjgregory at gmail dot com
Target Milestone: ---
Bug details:
When passing the -fhardened flag to cc help output is no longer displayed when
using --help=<topic> such as common, optimizers, params, target, warnings
unless a file is given to cc to process.
Reproduction Steps:
Step 1 - Run test:
cc -fhardened --help=warnings
Step 2 - FIN
Observe lack of help displayed.
Information:
GCC Version
cc (GCC) 15.2.1 20251112
----------------------------------------------------------------
Arch Linux - Linux endora 6.16.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 02 Oct
2025 19:26:36 +0000 x86_64 GNU/Linux
Processor: 9950x3d
Package: gcc 15.2.1+r301+gf24307422d1d-1
Name : gcc
Version : 15.2.1+r301+gf24307422d1d-1
Description : The GNU Compiler Collection - C and C++ frontends
Architecture : x86_64
URL : https://gcc.gnu.org
Licenses : GPL-3.0-with-GCC-exception GFDL-1.3-or-later
Groups : None
Provides : gcc-multilib
Depends On : gcc-libs=15.2.1+r301+gf24307422d1d-1 binutils>=2.28 libmpc
zstd libisl.so=23-64
Optional Deps : lib32-gcc-libs: for generating code for 32-bit ABI
[installed]
Required By : base-devel clang dkms rust vala
Optional For : None
Conflicts With : None
Replaces : gcc-multilib
Installed Size : 208.79 MiB
Packager : Frederik Schwan <[email protected]>
Build Date : Wed 12 Nov 2025 07:07:28 AM EST
Install Date : Fri 14 Nov 2025 11:25:50 AM EST
Install Reason : Installed as a dependency for another package
Install Script : No
Validated By : Signature
----------------------------------------------------------------
Exact build instructions for the compiler can be found here :
https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/blob/main/PKGBUILD?ref_type=heads
----------------------------------------------------------------
Shell: Bash
GNU bash, version 5.3.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
----------------------------------------------------------------
Edge case Analysis:
# Shows a list of warnings (OK) $? = 0
cc --help=warnings
# Shows a list of warnings (OK) $? = 0
cc --help=warnings t.c
# Still shows warnings options (OK) $? = 0
cc -fhardened --help=warnings t.c
# Produces no output at all (BUG?). $? = 0
cc -fhardened --help=warnings
In all cases t.c is just the results of the command `echo 'int
main(void){return 0;}' > t.c`
Workaround (Yes):
Just pass a dummy file into gcc when requesting --help=<topic>
`echo 'int main(void){return 0;}' | cc -fhardened --help=warnings -xc -`