https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122623
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by David Malcolm <[email protected]>: https://gcc.gnu.org/g:f1318516f07453e87814f6246acf567f684ac34f commit r16-7080-gf1318516f07453e87814f6246acf567f684ac34f Author: David Malcolm <[email protected]> Date: Tue Jan 27 16:36:29 2026 -0500 analyzer: add option -fanalyzer-assume-nothrow [PR122623] As of r16-264-g7a39e0ca0652ff, -fanalyzer assumes that a call to an external function not marked with attribute "nothrow" could throw an exception, if -fexceptions is enabled. PR analyzer/122623 notes that testing -fanalyzer with GCC 16 on Fedora packages turned up some new leak warnings due to -fexceptions being passed to all C code (for interoperability with C++), due to C headers typically not having their entrypoints being marked with "nothrow". Some of these are false positives. Others are arguably true positives, such as the case in the above report, but highly surprising to end-users, and of dubious value. I don't have data on the scale of the problem, but I am worried that the C++ exception support added in GCC 16 could cause a big regression in analyzer signal:noise when compiling C code with distro build flags. To provide a workaround for distro mass analysis runs, this patch adds a new option: -fanalyzer-assume-nothrow, which when enabled assumes that external functions do not throw exceptions. This may be something of a blunt hammer, but may be useful to distros to add to build flags for C. gcc/analyzer/ChangeLog: PR analyzer/122623 * analyzer.opt (fanalyzer-assume-nothrow): New. * analyzer.opt.urls: Regenerate. * region-model.cc (can_throw_p): Bail out if the user specified -fanalyzer-assume-nothrow. gcc/ChangeLog: PR analyzer/122623 * doc/invoke.texi (-fanalyzer-assume-nothrow): New option. gcc/testsuite/ChangeLog: PR analyzer/122623 * gcc.dg/analyzer/fexceptions-1.c: New test. * gcc.dg/analyzer/fexceptions-2.c: New test. Signed-off-by: David Malcolm <[email protected]>
