This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/80331] unused const std::string not optimized away


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

--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #2)
> I didn't check if those are the only blockers in this case...

Looks like they are indeed the only blockers, since we optimize the below just
fine. So, known issue (which doesn't mean we shouldn't do something about it).
(with 2 dead strings instead of 1, we need -O3, -O2 is not sufficient)

#include <bits/c++config.h>
#undef _GLIBCXX_EXTERN_TEMPLATE
#define _GLIBCXX_EXTERN_TEMPLATE 0
#include <string>
#include <memory>
inline void operator delete(void*p){__builtin_free(p);}
inline void* operator new(size_t n){return __builtin_malloc(n);}
int main() {
  const std::string s("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]