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

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning depends on the optimizer for eliminating unreachable code but not
all of it can be.  For example, the abort below isn't.  In theory it could be
but with longer strings that require memory allocation it gets harder.  As
discussed in pr98465, some sort of an attribute telling GCC that a and b's data
are disjoint might help.

void g (void)
{
  std::string a ("abcd");
  std::string b (a);
  if (a != b)
    __builtin_abort ();
}

In general, code that depends on pointer relationships is not handled optimally
in GCC.  Some unreachable code is introduced by GCC itself as a result of
passes like jump threading and that probably could be avoided.

Reply via email to