C28 64-bit integer multiply with post-increment incorrectly increments pointer too much

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Medium
    • Code Generation Tools
    • CODEGEN-14803
    • Hide
      C2000_16.9.0.LTS
      C2000_18.1.0.LTS
      C2000_22.6.0.LTS
      C2000_25.11.0.LTS
      C2000_15.12.0.LTS
      C2000_6.4.0
      C2000_21.6.0.LTS
      C2000_18.12.0.LTS
      C2000_20.2.0.LTS
      Show
      C2000_16.9.0.LTS C2000_18.1.0.LTS C2000_22.6.0.LTS C2000_25.11.0.LTS C2000_15.12.0.LTS C2000_6.4.0 C2000_21.6.0.LTS C2000_18.12.0.LTS C2000_20.2.0.LTS
    • Hide
      C2000_25.11.1.LTS*
      C2000_21.6.2.LTS*
      C2000_22.6.4.LTS*
      Show
      C2000_25.11.1.LTS* C2000_21.6.2.LTS* C2000_22.6.4.LTS*
    • default
    • Hide
      Disable optimizations: --opt_level=off

      Or change C code from using post increment per below:

      Workaround 1: Load into temporary variable first
      // bug
      long long result = base * (*mult_ptr++);
      // Avoid by loading into temporary, then incrementing separately
      long long temp = *mult_ptr;
      mult_ptr++;
      long long result = base * temp;

      Workaround 2: Use array indexing instead of pointer arithmetic
      // bug
      long long *ptr = array;
      for (int i = 0; i < n; i++) {
          result += base * (*ptr++);
      }
      // Avoid by using array indexing
      for (int i = 0; i < n; i++) {
          result += base * array[i];
      }

      Workaround 3: Manual pointer arithmetic with separate increment
      // bug
      long long result = base * (*mult_ptr++);
      // Avoid with manual arithmetic
      long long result = base * (*mult_ptr);
      mult_ptr = mult_ptr + 1;
      Show
      Disable optimizations: --opt_level=off Or change C code from using post increment per below: Workaround 1: Load into temporary variable first // bug long long result = base * (*mult_ptr++); // Avoid by loading into temporary, then incrementing separately long long temp = *mult_ptr; mult_ptr++; long long result = base * temp; Workaround 2: Use array indexing instead of pointer arithmetic // bug long long *ptr = array; for (int i = 0; i < n; i++) {     result += base * (*ptr++); } // Avoid by using array indexing for (int i = 0; i < n; i++) {     result += base * array[i]; } Workaround 3: Manual pointer arithmetic with separate increment // bug long long result = base * (*mult_ptr++); // Avoid with manual arithmetic long long result = base * (*mult_ptr); mult_ptr = mult_ptr + 1;

          Assignee:
          TI User
          Reporter:
          TI User
          Votes:
          0 Vote for this issue
          Watchers:
          2 Start watching this issue

            Created:
            Updated:
            Resolved:

              Connection: Intermediate to External PROD System
              EXTSYNC-6366 - C28 64-bit integer multiply with po...
              SYNCHRONIZED
              • Last Sync Date: