https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93844
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Tom de Vries from comment #4) > (In reply to Richard Biener from comment #1) > > The only way to capture these may > > be to introduce additional scoping in the FEs whenever new local decls > > are added. Also consider > > > > const char *oldst = st; > > const char *st = "Hello, world!"; > > > > so even consecutive inits may need two separate scopes. > > At the DWARF side, DW_AT_start_scope looks applicable: > ... > The debugging information entry for a program variable, formal parameter or > constant may have the following attributes: > ... > 11. A DW_AT_start_scope attribute if the scope of an object is smaller than > (that is, is a subset of the addresses of) the scope most closely enclosing > the object. > ... > > Maybe this can be generating without introducing additional scoping? One the DWARF side maybe. But on the GCC side all we have is the BLOCK tree and all FEs put the "late" declarations in the enclosing BLOCKs BLOCK_VARS. So DW_AT_start_scope would be an optimization that can be used to elide DW_TAG_lexical_block if the end of the enclosing scope is the same as the end of the current scope.