title: C26451 Arithmetic overflow accessing items in a CStringArray
body: <p>Got this code:</p>
  <pre><code>CString CMeetingScheduleAssistantApp::UpdateDateFormatString(COleDateTime&amp; rDate, CString strDateFormatString)
  {
      CString     strDayNumber, strNewDateFormatString = strDateFormatString;
  
      if (theApp.UseTranslationINI())
      {
          strNewDateFormatString.Replace(_T(&quot;%B&quot;),
              m_aryDateTrans[DATE_TRANS_MONTH][rDate.GetMonth() - 1]);
          strNewDateFormatString.Replace(_T(&quot;%A&quot;),
              m_aryDateTrans[DATE_TRANS_DAY][rDate.GetDayOfWeek() - 1]);
          strNewDateFormatString.Replace(_T(&quot;%b&quot;),
              m_aryDateTrans[DATE_TRANS_MONTH_SHORT][rDate.GetMonth() - 1]);
          strNewDateFormatString.Replace(_T(&quot;%a&quot;),
              m_aryDateTrans[DATE_TRANS_DAY_SHORT][rDate.GetDayOfWeek() - 1]);
  
          strDayNumber = rDate.Format(_T(&quot;%d&quot;));
          strNewDateFormatString.Replace(_T(&quot;%d&quot;), strDayNumber);
          strDayNumber = rDate.Format(_T(&quot;%#d&quot;));
          strNewDateFormatString.Replace(_T(&quot;%#d&quot;), strDayNumber);
      }
  
      return strNewDateFormatString;
  }
  </code></pre>
  <p>For the four <code>Replace</code> lines of code I am getting code analysis warning:</p>
  <blockquote>
  <p>Warning C26451</p>
  <p>Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2).</p>
  </blockquote>
  <p>The first value inside the <code>[</code> and <code>]</code> brackets is of type <code>int</code>, but the second is a literal value of <code>1</code>:</p>
  <p><a href="https://i.stack.imgur.com/b02RJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b02RJ.jpg" alt="Code" /></a></p>
  <p>The variable <code>m_aryDateTrans</code> is defined as:</p>
  <pre><code>CStringArray m_aryDateTrans[NUM_DATE_TRANS];
  </code></pre>
  <p>So I am not sure what casting I need to make here to suppress this warning.</p>
  <p>I am compiling in 32 bit and 64 bit environments.</p>