libstdc++: Do not use std::vector<bool>::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<bool> 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<bool>::reference.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
This commit is contained in:
Jonathan Wakely 2024-08-27 13:30:42 +01:00 committed by Jonathan Wakely
parent 470a27859d
commit 75ef21665c
No known key found for this signature in database
3 changed files with 3 additions and 6 deletions

View File

@ -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<bool>::reference'
return bool(self._val['_M_p'].dereference() & (self._val['_M_mask']))

View File

@ -153,9 +153,6 @@ main()
std::vector<bool>::reference br5 = *vbIt5;
// { dg-final { note-test br5 {true} } }
std::vector<bool>::reference br0;
// { dg-final { note-test br0 {invalid std::vector<bool>::reference} } }
__gnu_cxx::slist<int> sll;
sll.push_front(23);
sll.push_front(47);

View File

@ -146,9 +146,6 @@ main()
std::vector<bool>::reference br5 = *vbIt5;
// { dg-final { note-test br5 {true} } }
std::vector<bool>::reference br0;
// { dg-final { note-test br0 {invalid std::vector<bool>::reference} } }
__gnu_cxx::slist<int> sll;
sll.push_front(23);
sll.push_front(47);