https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124327

            Bug ID: 124327
           Summary: Contents of vector not pretty-printable if using C++23
                    and including sstream before vector
           Product: gcc
           Version: 14.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Oliver.Old at loewen dot de
  Target Milestone: ---

Created attachment 63803
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63803&action=edit
Test program

When debugging a test program that includes sstream before vector, GDB's pretty
printers cannot find nested types used as element type of the vector in certain
cases. The issue manifests as "Cannot instantiate printer for default
visualizer" being returned for the variable. This issue occurs when the binary
was compiled with --std=c++23, but not with --std=c++20 or when vector is
included before sstream.

In my test program this somehow seems to be triggered when a default template
parameter is used. It doesn't occur when C3 is passed explicitly as second
template parameter. In another case that I couldn't isolate, it was triggered
by a function-scope struct in a class method.

Reproduced with a custom-built cross-GCC 14.3 targeting an x86 Linux system and
the native ucrt64 GCC 15.2 shipped by MSYS2.

When enabling full Python stack traces, this is returned when trying to print
the variable's value:

Traceback (most recent call last):
  File
"C:\msys64/ucrt64/share/gdb/python/../../gcc-15.2.0/python\libstdcxx\v6\printers.py",
line 2436, in __call__
    return self._lookup[basename].invoke(val)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File
"C:\msys64/ucrt64/share/gdb/python/../../gcc-15.2.0/python\libstdcxx\v6\printers.py",
line 2369, in invoke
    return self._function(self.name, value)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File
"C:\msys64/ucrt64/share/gdb/python/../../gcc-15.2.0/python\libstdcxx\v6\printers.py",
line 563, in __init__
    self._is_bool = val.type.template_argument(
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^
        0).code == gdb.TYPE_CODE_BOOL
        ^^
gdb.error: No type named B<C>::S.
Traceback (most recent call last):
  File
"C:\msys64/ucrt64/share/gdb/python/../../gcc-15.2.0/python\libstdcxx\v6\printers.py",
line 2436, in __call__
    return self._lookup[basename].invoke(val)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File
"C:\msys64/ucrt64/share/gdb/python/../../gcc-15.2.0/python\libstdcxx\v6\printers.py",
line 2369, in invoke
    return self._function(self.name, value)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File
"C:\msys64/ucrt64/share/gdb/python/../../gcc-15.2.0/python\libstdcxx\v6\printers.py",
line 563, in __init__
    self._is_bool = val.type.template_argument(
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~^
        0).code == gdb.TYPE_CODE_BOOL
        ^^
gdb.error: No type named B<C>::S.
$1 = {<std::_Vector_base<B<C>::S, std::allocator<B<C>::S> >> = {_M_impl =
{<std::allocator<B<C>::S>> = {<std::__new_allocator<B<C>::S>> = {<No data
fields>}, <No data fields>}, <std::_Vector_base<B<C>::S,
std::allocator<B<C>::S> >::_Vector_impl_data> = {_M_start = 0x8050370,
_M_finish = 0x8050378, _M_end_of_storage = 0x8050378}, <No data fields>}}, <No
data fields>}

Compile test program with:

g++ -std=c++23 -g -o test test.cpp

vs.

g++ -std=c++20 -g -o test test.cpp

Reply via email to