Analyzer fixes ICE when undoing cast of va_list pointer.
Resolves an internal compiler error related to `va_list` pointer casting in the analyzer.
An internal compiler error occurred in the GCC analyzer when processing va_list pointers due to an incorrect handling of casts. The get_va_copy_arg function would strip any cast from a va_list pointer, even if the result wasn’t a pointer, leading to an assertion failure. This fix ensures that casts are only undone when the result is indeed a pointer type, preventing the ICE and fixing related test failures.
In Details
The analyzer::get_va_copy_arg function in varargs.cc now correctly handles casts applied to va_list pointers. Previously, it unconditionally stripped casts, which could result in a non-pointer type being dereferenced by deref_rvalue, triggering an assertion. This commit modifies the function to only undo casts that yield a pointer type, resolving an ICE and a new test case involving va_copy and casts.
- analyzer
- A GCC component that statically analyzes code to find potential bugs, such as use-after-free, buffer overflows, and uninitialized values, without executing the code.
- ICE
- Internal Compiler Error. A fatal error encountered by the compiler during its execution, typically indicating a bug in the compiler itself.
- va_list
- A type defined in
<stdarg.h>used to hold information about variable arguments passed to a function.va_copyis a macro used to create a copy of ava_list.