gcc/libstdc++-v3/testsuite/ext/malloc_allocator/sanity.cc

32 lines
1.1 KiB
C++
Raw Permalink Normal View History

2025-01-02 11:59:57 +01:00
// Copyright (C) 2016-2025 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-do run { target c++11 } }
#include <map>
#include <vector>
#include <ext/malloc_allocator.h>
int main()
{
std::map<int, int, std::less<int>,
Fix tests that use allocators with incorrect value types As a GNU extension we allow containers to be instantiated with allocators that use a different value type from the container, and automatically rebind the allocator to the correct type. This extension is disabled in strict modes (when __STRICT_ANSI__ is defined, i.e. -std=c++NN dialects). These testcases unintentionally rely on the extension and so fail for strict modes. Tests which intentionally make use of the extension will still fail in strict dialects, but will be addressed in a later change. * testsuite/20_util/scoped_allocator/1.cc: Use allocator with correct value type for the container. * testsuite/23_containers/forward_list/cons/14.cc: Likewise. * testsuite/23_containers/map/56613.cc: Likewise. * testsuite/23_containers/unordered_map/55043.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/copy.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/copy_assign.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/minimal.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/move.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/move_assign.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_map/cons/81891.cc: Likewise. * testsuite/23_containers/unordered_map/requirements/exception/ basic.cc: Likewise. * testsuite/23_containers/unordered_map/requirements/exception/ generation_prohibited.cc: Likewise. * testsuite/23_containers/unordered_map/requirements/exception/ propagation_consistent.cc: Likewise. * testsuite/23_containers/unordered_multimap/55043.cc: Likewise. * testsuite/23_containers/unordered_multimap/allocator/copy.cc: Likewise. * testsuite/23_containers/unordered_multimap/allocator/copy_assign.cc: Likewise. * testsuite/23_containers/unordered_multimap/allocator/minimal.cc: Likewise. * testsuite/23_containers/unordered_multimap/allocator/move.cc: Likewise. * testsuite/23_containers/unordered_multimap/allocator/move_assign.cc: Likewise. * testsuite/23_containers/unordered_multimap/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_multimap/requirements/exception/ basic.cc: Likewise. * testsuite/23_containers/unordered_multimap/requirements/exception/ generation_prohibited.cc: Likewise. * testsuite/23_containers/unordered_multimap/requirements/exception/ propagation_consistent.cc: Likewise. * testsuite/23_containers/unordered_multimap/requirements/ explicit_instantiation/5.cc: Likewise. * testsuite/ext/malloc_allocator/sanity.cc: Likewise. From-SVN: r265331
2018-10-19 22:49:40 +01:00
__gnu_cxx::malloc_allocator<std::pair<const int, int> > > allocs;
allocs[9] = 3;
std::vector<int, __gnu_cxx::malloc_allocator<int>> vec(10);
vec[5] = 42;
}