GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
codeview

Codeview skips local variables without names [PR124432].

Fixes crashes and orphaned debug records by skipping unnamed local variables during CodeView symbol generation.

This change prevents crashes and the emission of orphaned debug records by ensuring that local variables without names are skipped during CodeView symbol generation. Previously, attempting to emit symbols for such variables led to null pointer dereferences. The fix applies to both unoptimized and optimized symbol writers, and specifically handles optimized locals by skipping them before emitting location ranges, thus avoiding issues with S_LOCAL and S_DEFRANGE records.

In Details

Artificial local variables generated by the compiler can lack a DW_AT_name attribute. The existing CodeView symbol writers in dwarf2codeview.cc would dereference a null pointer when attempting to emit symbols for these unnamed variables. This commit modifies write_local_s_ldata32, write_s_register, write_fbreg_variable, and write_optimized_local_variable to skip such unnamed locals. For optimized locals, it ensures they are skipped before emitting their location ranges, preventing orphaned S_DEFRANGE records.

For Context
DW_AT_name
An attribute within a DWARF DIE that specifies the name of the entity the DIE represents.
CodeView
A proprietary debug information format developed by Microsoft, commonly used with the Visual C++ compiler and on Windows platforms. GCC supports generating CodeView debug info.
S_LOCAL
A CodeView symbol type that describes a local variable within a function's scope.
S_DEFRANGE
A CodeView symbol type used to describe the range of addresses where a variable is valid, particularly in optimized code.
Filed Under: debugcodeviewcompiler bug