https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98465
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |redi at gcc dot gnu.org --- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, if adding some attribute or whatever to std::string etc. members doesn't look doable/desirable, can't we e.g. implement _M_disjunct using some builtin that would allow gcc to optimize it better (and later fold it into how it is implemented now)? It is currently: // True if _Rep and source do not overlap. bool _M_disjunct(const _CharT* __s) const _GLIBCXX_NOEXCEPT { return (less<const _CharT*>()(__s, _M_data()) || less<const _CharT*>()(_M_data() + this->size(), __s)); } and when std::basic_string uses the normal allocators, _M_dataplus._M_p can point either to some heap allocated object or to _M_local_buf inside of *this. So, can some template stuff ensure that the builtin would be only used when using a standard allocator and not something that can say have a global: char buffer[0x10000000]; and allocate from that? Pass to the builtin all the needed info (e.g. return __builtin_whatever_disjunct (_M_data(), this->size(), _M_local_data(), __s); ) and let it use points to info to fold it to false if the last pointer can't point to either _M_local_data() pointed object or heap memory, otherwise fold into pointer sized casts of the pointers and integral comparisons as before?