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 middle-end/77357] strlen of constant strings not folded


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Sorry, wrong test case.  Here's the right one:

const char a[] = "abc";
const char* const s = "abc";

void global_array (void)
{
  if (__builtin_strlen (a) != 3)
    __builtin_abort ();
}

void local_array (void)
{
  static const char a[] = "abc";
  if (__builtin_strlen (a) != 3)
    __builtin_abort ();
}

void global_pointer (void)
{
  if (__builtin_strlen (s) != 3)
    __builtin_abort ();
}

void local_pointer (void)
{
  static const char* const s = "abc";
  if (__builtin_strlen (s) != 3)
    __builtin_abort ();
}


struct X { char a [4]; };
const struct X x = { "abc" };

void global_struct (void)
{
  if (__builtin_strlen (x.a) != 3)
    __builtin_abort ();
}

void local_struct (void)
{
  static const struct X x =  { "abc" };
  if (__builtin_strlen (x.a) != 3)
    __builtin_abort ();
}

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