<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; vertical-align: baseline; -webkit-text-size-adjust: 100%; line-height: 18px; font-size: 15px; font-family: 'Helvetica Neue', Helvetica, 'Droid Sans', DroidSansRegular, Arial, sans-serif; color: rgb(34, 34, 34);">Hi,</p><p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; vertical-align: baseline; -webkit-text-size-adjust: 100%; line-height: 18px; font-size: 15px; font-family: 'Helvetica Neue', Helvetica, 'Droid Sans', DroidSansRegular, Arial, sans-serif; color: rgb(34, 34, 34);">I am puzzled by the result of std::vector<char>::max_size() on the n = 32 and n = 64 bits system I have tested. The result is 2^n − 1. Let me explain why I am puzzled.</p><p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; vertical-align: baseline; -webkit-text-size-adjust: 100%; line-height: 18px; font-size: 15px; font-family: 'Helvetica Neue', Helvetica, 'Droid Sans', DroidSansRegular, Arial, sans-serif; color: rgb(34, 34, 34);"><br></p><p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; vertical-align: baseline; -webkit-text-size-adjust: 100%; line-height: 18px; font-size: 15px; font-family: 'Helvetica Neue', Helvetica, 'Droid Sans', DroidSansRegular, Arial, sans-serif; color: rgb(34, 34, 34);">Every implementation of std::vector<T> that I know of, libc++ included, has three members of type T*: begin_, end_, capacity_. begin_ points to the first value of the vector and end_ points to the one after the last. The size() method is computes end_ - begin_. But the result of this difference is of type std::ptrdiff_t which is a signed integer of n bits on every implementation that I know of. Therefore, this type can not store the integer 2^n − 1, but only up to 2^(n − 1) − 1.</p><p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; vertical-align: baseline; -webkit-text-size-adjust: 100%; line-height: 18px; font-size: 15px; font-family: 'Helvetica Neue', Helvetica, 'Droid Sans', DroidSansRegular, Arial, sans-serif; color: rgb(34, 34, 34);"><br></p><p style="margin: 0px 0px 0.8em; padding: 0px; border: 0px; vertical-align: baseline; -webkit-text-size-adjust: 100%; line-height: 18px; font-size: 15px; font-family: 'Helvetica Neue', Helvetica, 'Droid Sans', DroidSansRegular, Arial, sans-serif; color: rgb(34, 34, 34);">I would expect this last number for max_size(). Is it a bug or something that I overlooked?</p></body></html>