https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126484
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:046f8f3134c29cb6c760e69cb2eeb3db8a644a62 commit r16-9499-g046f8f3134c29cb6c760e69cb2eeb3db8a644a62 Author: Jakub Jelinek <[email protected]> Date: Mon Aug 3 11:26:11 2026 +0200 mips: Fix up creation of MD builtins with 0 arguments [PR126484] For MIPS_SI_FTYPE_VOID and MIPS_USI_FTYPE_VOID which are meant for functions which return (SImode) int or unsigned int and have (void) arguments the MIPS backend creates those using case MIPS_SI_FTYPE_VOID: types[(int) type] = build_function_type_list (intSI_type_node, void_type_node, NULL_TREE); break; case MIPS_USI_FTYPE_VOID: types[(int) type] = build_function_type_list (unsigned_intSI_type_node, void_type_node, NULL_TREE); break; That is wrong, because functions which don't take any arguments (i.e. (void) or C23/C++ ()) should be using void_list_node as TYPE_ARG_TYPES, not a TREE_LIST with void_type_node TREE_VALUE and TREE_CHAIN being that void_list_node. Although void_list_node also has TREE_VALUE of void_type_node, various places in the C++ FE as well as in the middle-end rely on void_list_node to be unique, compare it using pointer comparison. The following testcase strangely happens to compile fine when compiled in C, but fails in C++ (which reports wrong number of arguments due to this bug). The following simple patch just arranges those 0 argument functions to have the MIPS_*_FTYPE_VOID enumerators be named as before, but in the build_function_type_list call omit that ", void_type_node" part, so it creates correct 0 arguments FUNCTION_TYPE. 2026-08-03 Jakub Jelinek <[email protected]> PR target/126484 * config/mips/mips-ftypes.def (MIPS_SI_FTYPE_VOID, MIPS_USI_FTYPE_VOID): Use DEF_MIPS_FTYPE with 0 as first argument rather than 1 and leave out ", VOID" from second argument. * config/mips/mips.cc (MIPS_FTYPE_NAME0): Define. (MIPS_FTYPE_ATYPES0): Define. * g++.target/mips/pr126484.C: New test. Reviewed-by: Richard Biener <[email protected]> (cherry picked from commit e152b584c3df7ce0ef738f3d7c2d852490d59e3d)
