title: Is it undefined behavior to compare a character array char u[10] with a string literal "abc"
body: <p>I came across <a href="https://stackoverflow.com/questions/71303821/tell-me-where-am-i-doing-mistake/">this</a> question on SO, and <a href="https://stackoverflow.com/a/71303981/15545927">this</a> answer to the question. The code is as follows:</p>
  <pre><code>int main()
  {
  
      char u[10];
      cout&lt;&lt;&quot;Enter shape name &quot;;
      cin&gt;&gt;u;
      if(u==&quot;tri&quot;) //IS THIS UNDEFINED BEHAVIOR because the two decayed pointers both point to unrelated objects?
      {
          cout&lt;&lt;&quot;everything is fine&quot;;
      }
      else
      {
          cout&lt;&lt;&quot;Not fine&quot;;
      }
      return 0;
  }
  </code></pre>
  <p>I have read in the mentioned answer that, both <code>u</code> and <code>&quot;tri&quot;</code> decay to pointers to their first element. My question is that, now is comparing these two decayed pointers <strong>undefined  behavior</strong> because these pointers point to unrelated objects? Or the program is fine/valid(no UB) and because the pointers have different values, the else branch will be executed?</p>