From: Jonathan Wakely Date: Tue, 27 Aug 2024 12:30:42 +0000 (+0100) Subject: libstdc++: Do not use std::vector::reference default ctor [PR115098] X-Git-Tag: basepoints/gcc-16~6335 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75ef21665cb924265b818b08babbc7ec3108c876;p=thirdparty%2Fgcc.git libstdc++: Do not use std::vector::reference default ctor [PR115098] This default constructor was made private by r15-3124-gb25b101bc38000 so the pretty printer tests need a fix to stop using it. There's no conforming way to get a default-constructed 'reference' now, e.g. trying to access an element of a default-constructed std::vector will trigger an assertion. Remove the tests, but leave a comment in the printer code about handling it. libstdc++-v3/ChangeLog: PR libstdc++/115098 * python/libstdcxx/v6/printers.py (StdBitReferencePrinter): Add comment. * testsuite/libstdc++-prettyprinters/simple.cc: Do not default construct std::vector::reference. * testsuite/libstdc++-prettyprinters/simple11.cc: Likewise. --- diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index a6c2ed4599fa..921049378627 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -613,6 +613,9 @@ class StdBitReferencePrinter(printer_base): def to_string(self): if not self._val['_M_p']: + # PR libstdc++/115098 removed the reference default constructor + # that this case relates to. New code should never need this, + # but we still handle it for compatibility with old binaries. return 'invalid std::vector::reference' return bool(self._val['_M_p'].dereference() & (self._val['_M_mask'])) diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc index 7bdc6548f727..c6d18d3fe03c 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc @@ -153,9 +153,6 @@ main() std::vector::reference br5 = *vbIt5; // { dg-final { note-test br5 {true} } } - std::vector::reference br0; -// { dg-final { note-test br0 {invalid std::vector::reference} } } - __gnu_cxx::slist sll; sll.push_front(23); sll.push_front(47); diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc index 3658e3ef4eb4..7fd0c4d76b2a 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc @@ -146,9 +146,6 @@ main() std::vector::reference br5 = *vbIt5; // { dg-final { note-test br5 {true} } } - std::vector::reference br0; -// { dg-final { note-test br0 {invalid std::vector::reference} } } - __gnu_cxx::slist sll; sll.push_front(23); sll.push_front(47);