[Bug libstdc++/78448] New: Container max_size() functions don't consider the range of their difference_type

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 21 13:50:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78448

            Bug ID: 78448
           Summary: Container max_size() functions don't consider the
                    range of their difference_type
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#include <vector>
#include <limits>
#include <cassert>

int main() {
 using V = std::vector<char>;
 V v;
 assert(v.max_size() <= std::numeric_limits<V::difference_type>::max());
}

The requirement is that max_size() returns:

   distance(begin(), end()) for the largest possible container

which must fit in Container::difference_type


More information about the Gcc-bugs mailing list