]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Make __gnu_test:uneq_allocator(int) constructor explicit.
authorTomasz Kamiński <tkaminsk@redhat.com>
Thu, 12 Feb 2026 21:50:16 +0000 (22:50 +0100)
committerTomasz Kamiński <tkaminsk@redhat.com>
Fri, 13 Feb 2026 10:09:34 +0000 (11:09 +0100)
commitfa1149534d8580cfb88f2a82cd44d42033503206
tree0e1ffd4523e81697110161598f2d41740ae05157
parent4f9a973a3fdd59076d23b34d95f96d7c581f3968
libstdc++: Make __gnu_test:uneq_allocator(int) constructor explicit.

Presence implicit conversion from int to it's allocator, makes constructing
string from rvalue of same string type and int ambiguous, as none of following
candidates is better:
  basic_string(basic_string&&, allocator_type)
  // conversion from int to allocator for second argument
  basic_string(const basic_string&, int, allocator_type)
  // reference adjustment for first argument

This makes __gnu_test:uneq_allocator(int) constructor explicit, to avoid
above issues.

libstdc++-v3/ChangeLog:

* testsuite/20_util/scoped_allocator/construct_pair_c++2a.cc
(__gnu_test::uneq_allocator(int)): Declare as explicit.
* testsuite/std/memory/indirect/ctor.cc: Construct uneq_allocator
from int explicitly.
* testsuite/std/memory/polymorphic/ctor.cc: Likewise.
* testsuite/std/memory/polymorphic/ctor_poly.cc: Likewise.
* testsuite/util/testsuite_allocator.h: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/testsuite/20_util/scoped_allocator/construct_pair_c++2a.cc
libstdc++-v3/testsuite/std/memory/indirect/ctor.cc
libstdc++-v3/testsuite/std/memory/polymorphic/ctor.cc
libstdc++-v3/testsuite/std/memory/polymorphic/ctor_poly.cc
libstdc++-v3/testsuite/util/testsuite_allocator.h