Skip to content

Bogus warnings: warning: 'allocator<void>' is deprecated #49643

@jwakely

Description

@jwakely
mannequin
Bugzilla Link 50299
Resolution FIXED
Resolved on Jun 23, 2021 09:31
Version 11.0
OS Linux
Blocks #48661
CC @dwblaikie,@ldionne,@mclow,@tstellar,@viccpp
Fixed by commit(s) 87784cc e7dac56

Extended Description

#include <memory>

int main()
{
  std::allocator<void> a;
}


alloc.C:5:8: warning: 'allocator<void>' is deprecated [-Wdeprecated-declarations]
  std::allocator<void> a;
       ^
/usr/bin/../include/c++/v1/memory:725:28: note: 'allocator<void>' has been explicitly marked deprecated here
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void>
                           ^
/usr/bin/../include/c++/v1/__config:1035:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
#  define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
                                      ^
/usr/bin/../include/c++/v1/__config:1012:48: note: expanded from macro '_LIBCPP_DEPRECATED'
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
                                               ^

This warning is misleading and unhelpful. It's true that the explicit specialization is deprecated in C++17 and gone in C++20, but that doesn't mean users can't use std::allocator<void> in C++20. It just means that doing so uses the primary template.

It's perfectly fine to use std::allocator in C++17 in limited ways (e.g. you can't use it to allocate, obviously) and it's perfectly fine to use it in the same ways in C++20. Telling users it's deprecated is totally unhelpful, because they don't need to stop using it, but they can't do anything about the warnings except to stop using it.

What purpose do the warnings serve? What do you expect users to do if they get that warning? Why should they change their code, when there's nothing wrong with it?

Please revert the additions of the deprecated attributes here.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions