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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2018-07-06
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot 
gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Another test case for the same limitation:

const char a[4] = "123";
const char b[4] = "123";

int f (void)
{
  return __builtin_memcmp (a, b, 4);   // folded
}

const char c[4] = "123\0";   // sizeof "123\0" == 5

int g (void)
{
  return __builtin_memcmp (a, c, 4);   // not folded
}

The solution seems simple: change the string_constant() function to avoid
considering as string constants the strings of the last form, i.e., those with
more initializers than fit in the array they're stored in).

Reply via email to