view gcc/testsuite/gcc.dg/strcmpopt_11.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

/* Verify that strcmp doesn't make assumptions about the size of a weak
   symbol.
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

/* An ordinary definition of A with more elements might be provided
   in another translation unit.  Even though that would be undefined
   (the type of the actual definition must be the same as the type
   of the weak declaration) this test verifies that GCC doesn't rely
   on the size of this A for optimization (as a matter of QoI).  */
__attribute__ ((weak)) char a[3];

int cmp_a3_x (void)
{
  return __builtin_strcmp (a, "1234567") == 0;
}