[Bug c/125261] _Generic -Wuseless-cast false positive
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed May 13 04:59:19 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125261
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Uecker <uecker@gcc.gnu.org>:
https://gcc.gnu.org/g:dee30fc0e980ee26a804a74da74decc0cea10b8f
commit r17-483-gdee30fc0e980ee26a804a74da74decc0cea10b8f
Author: Martin Uecker <uecker@tugraz.at>
Date: Tue May 12 07:11:38 2026 +0200
c: avoid false positive for useless casts and generic [PR125261]
To reduce the number of false positives, we guard -Wuseless-cast by
c_inhibit_evaluation_warnings and also increment it for a generic
association if we have seen a prior match for a (non-default)
association. This covers the common case where the default association
comes last. If there is another association selected after we have
seen a default, we still have false positives.
PR c/125261
gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Modify logic for
c_inhibit_evaluation_warnings.
* c-typeck.cc (build_c_cast): Use c_inhibit_evaluation_warnings.
gcc/testsuite/ChangeLog:
* gcc.dg/pr125261.c: New test.
More information about the Gcc-bugs
mailing list