(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
Warray-compare-1.c
       1  /* PR c++/97573 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-Wall" } */
       4  
       5  #ifndef __cplusplus
       6  # define bool _Bool
       7  #endif
       8  
       9  int arr1[5];
      10  int arr2[5];
      11  int arr3[2][2];
      12  int arr4[2][2];
      13  
      14  bool
      15  g ()
      16  {
      17    bool b = arr1 == arr2; /* { dg-warning "comparison between two arrays" } */
      18    b &= arr1 != arr2; /* { dg-warning "comparison between two arrays" } */
      19    b &= arr1 > arr2; /* { dg-warning "comparison between two arrays" } */
      20    b &= arr1 >= arr2; /* { dg-warning "comparison between two arrays" } */
      21    b &= arr1 < arr2; /* { dg-warning "comparison between two arrays" } */
      22    b &= arr1 <= arr2; /* { dg-warning "comparison between two arrays" } */
      23  #ifdef __cplusplus
      24    b &= +arr1 == +arr2;
      25    b &= +arr1 != +arr2;
      26    b &= +arr1 > +arr2;
      27    b &= +arr1 >= +arr2;
      28    b &= +arr1 < +arr2;
      29    b &= +arr1 <= +arr2;
      30  #endif
      31    b &= &arr1[0] == &arr2[0];
      32    b &= &arr1[0] != &arr2[0];
      33    b &= &arr1[0] > &arr2[0];
      34    b &= &arr1[0] >= &arr2[0];
      35    b &= &arr1[0] < &arr2[0];
      36    b &= &arr1[0] <= &arr2[0];
      37  
      38    b &= arr3 == arr4; /* { dg-warning "comparison between two arrays" } */
      39  
      40  #if defined(__cplusplus) && __cplusplus > 201703L
      41    auto cmp = arr1 <=> arr2; /* { dg-error "invalid operands" "" { target c++20 } } */
      42  #endif
      43    return b;
      44  }