Debugger: Fix custom allocator dumper tests for GCC >= 13

GCC commit [1]

    commit 64c986b49558a7c356b85bda85195216936c29a3
    Author: Jonathan Wakely <jwakely@redhat.com>
    Date:   Wed Dec 14 15:21:32 2022 +0000

        libstdc++: Diagnose broken allocator rebind members

added a static_assert that caused the dumper tests using custom
allocators to fail like this on Debian testing:

    DEBUG : tst_Dumpers::dumper(StdBasicString) qtc.debugger.dumpers: In file included from /usr/include/c++/13/ext/alloc_traits.h:34,
                     from /usr/include/c++/13/bits/basic_string.h:39,
                     from /usr/include/c++/13/string:54,
                     from main.cpp:28:
    /usr/include/c++/13/bits/alloc_traits.h: In instantiation of ‘struct std::__allocator_traits_base::__rebind<myallocator<char>, char, void>’:
    /usr/include/c++/13/bits/alloc_traits.h:94:11:   required by substitution of ‘template<class _Alloc, class _Up> using std::__alloc_rebind = typename std::__allocator_traits_base::__rebind<_Alloc, _Up>::type [with _Alloc = myallocator<char>; _Up = char]’
    /usr/include/c++/13/bits/alloc_traits.h:228:8:   required by substitution of ‘template<class _Alloc> template<class _Tp> using std::allocator_traits< <template-parameter-1-1> >::rebind_alloc = std::__alloc_rebind<_Alloc, _Tp> [with _Tp = char; _Alloc = myallocator<char>]’
    /usr/include/c++/13/ext/alloc_traits.h:126:65:   required from ‘struct __gnu_cxx::__alloc_traits<myallocator<char>, char>::rebind<char>’
    /usr/include/c++/13/bits/basic_string.h:90:24:   required from ‘class std::__cxx11::basic_string<char, std::char_traits<char>, myallocator<char> >’
    main.cpp:56:71:   required from here
    /usr/include/c++/13/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits<A>::rebind_alloc<A::value_type> must be A
       70 |                         _Tp>::value,
          |                               ^~~~~
    /usr/include/c++/13/bits/alloc_traits.h:70:31: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
    make: *** [Makefile:506: main.o] Error 1

Override the rebind behavior of the custom allocator used
in the tests to fix this.

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=64c986b49558a7

Change-Id: I1cd8370e5f1601b710e28c251061291c65ac44ce
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Michael Weghorn
2024-02-08 12:22:24 +01:00
parent 0b44cc5589
commit 3b5c377ce5

View File

@@ -5264,7 +5264,12 @@ void tst_Dumpers::dumper_data()
<< Data("#include <string>\n"
"template<class T>\n"
"class myallocator : public std::allocator<T> {};\n",
"class myallocator : public std::allocator<T> {\n"
"template<typename _Tp1>\n"
"struct rebind {\n"
"typedef myallocator<_Tp1> other;\n"
"};\n"
"};\n",
"std::basic_string<char, std::char_traits<char>, myallocator<char>> str(\"hello\");",
@@ -5418,6 +5423,10 @@ void tst_Dumpers::dumper_data()
"template<class T>\n"
"class myallocator : public std::allocator<T> {\n"
"using std::allocator<T>::allocator;\n"
"template<typename _Tp1>\n"
"struct rebind {\n"
"typedef myallocator<_Tp1> other;\n"
"};\n"
"};\n",
"std::vector<double> v0, v1;\n"