C: Fix up ICE with __builtin_{bswap,bitreverse}g
GCC no longer crashes when processing `__builtin_bswapg` and `__builtin_bitreverseg` with non-folded arguments.
This commit resolves an Internal Compiler Error (ICE) that occurred in GCC when processing __builtin_bswapg and __builtin_bitreverseg builtins with arguments that hadn’t been fully folded. Previously, the compiler would crash because it expected a folded argument before calling fold_build_builtin_bswapg_bitreverseg. The fix now ensures that c_fully_fold is called on the argument before the builtin construction, preventing the ICE and improving compiler stability for C code using these operations.
In Details
This fix targets an ICE within c-parser.cc when handling __builtin_bswapg and __builtin_bitreverseg in the C frontend. The issue stemmed from fold_build_builtin_bswapg_bitreverseg expecting a fully_folded_operand which was not always guaranteed. The patch ensures that c_fully_fold is invoked on the builtin's argument prior to the call to fold_build_builtin_bswapg_bitreverseg. This addresses the type expectation mismatch, preventing an ICE during expression folding for generic byte-swap and bit-reverse operations, primarily impacting case RID_BUILTIN_BSWAPG within `c_parser_pos…
For Context
This update fixes a stability issue in GCC, the GNU Compiler Collection, specifically when compiling C code. Sometimes, during compilation, the compiler can experience an "Internal Compiler Error" (ICE), which is essentially a crash within the compiler itself. This particular ICE happened when developers used special built-in functions like __builtin_bswapg (byte swap) or __builtin_bitreverseg (bit reverse) on numbers that weren't fully processed or 'folded' into their final constant values yet. The compiler was expecting these values to be finalized before it tried to create the machine instructions for these built-in functions. The fix ensures that any argument to these built-in functions is fully processed before the compiler attempts to use it, preventing the crash and making the compiler more robust.