C++ feature causes runtime failure on unaligned access on ARM9

XMLWordPrintable

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Medium
    • Code Generation Tools
    • CODEGEN-4304
    • Hide
      ARM_18.1.0.LTS
      MSP430_18.1.0.LTS
      MSP430_20.2.0.LTS
      ARM_18.12.0.LTS
      ARM_19.6.0.STS
      MSP430_18.12.0.LTS
      MSP430_19.6.0.STS
      ARM_20.2.0.LTS
      C2000_20.2.0.LTS
      Show
      ARM_18.1.0.LTS MSP430_18.1.0.LTS MSP430_20.2.0.LTS ARM_18.12.0.LTS ARM_19.6.0.STS MSP430_18.12.0.LTS MSP430_19.6.0.STS ARM_20.2.0.LTS C2000_20.2.0.LTS
    • Hide

      Update 5/8/2020:

      The enclosed test case contains a "while (it00++ != g.end())" which will cause undefined behavior at runtime (which in the reported case is an attempted unaligned access). The problem arises on the last iteration where the compiler is forced to increment an iterator that is already pointing to g.end(), which is undefined behavior.

      Original Description:

      The following code results in an unaligned access failure in the ARM simulator when compiled with:

      armcl -mv5e -me --float_support=vfpv2

      #include <map>
      #include <stdio.h>

      int main(void)
      {
              std::map<int, char>::size_type n=9;
              std::map<int, char> g;
              char s[] = "contrived";
              for (int i=0; i<n; i++) {
                  char k = s[i];
                  std::pair<const int, char> p((int)k, k);
                  g.insert(p);
              }

              int i00 = 0;
              std::map<int, char>::iterator it00 = g.begin();
              printf("start for loop\n");
              while (it00++ != g.end())
              {
                 printf("iteration %d\n", i00++);
              }
              printf("out of for loop\n");
              return (1);
      }
      Show
      Update 5/8/2020: The enclosed test case contains a "while (it00++ != g.end())" which will cause undefined behavior at runtime (which in the reported case is an attempted unaligned access). The problem arises on the last iteration where the compiler is forced to increment an iterator that is already pointing to g.end(), which is undefined behavior. Original Description: The following code results in an unaligned access failure in the ARM simulator when compiled with: armcl -mv5e -me --float_support=vfpv2 #include <map> #include <stdio.h> int main(void) {         std::map<int, char>::size_type n=9;         std::map<int, char> g;         char s[] = "contrived";         for (int i=0; i<n; i++) {             char k = s[i];             std::pair<const int, char> p((int)k, k);             g.insert(p);         }         int i00 = 0;         std::map<int, char>::iterator it00 = g.begin();         printf("start for loop\n");         while (it00++ != g.end())         {            printf("iteration %d\n", i00++);         }         printf("out of for loop\n");         return (1); }
    • Hide
      The enclosed test case contains a "while (it00++ != g.end())" which will cause undefined behavior at runtime (which in the reported case is an attempted unaligned access). The problem arises on the last iteration where the compiler is forced to increment an iterator that is already pointing to g.end(), which is undefined behavior.

      User error.
      Show
      The enclosed test case contains a "while (it00++ != g.end())" which will cause undefined behavior at runtime (which in the reported case is an attempted unaligned access). The problem arises on the last iteration where the compiler is forced to increment an iterator that is already pointing to g.end(), which is undefined behavior. User error.

      The enclosed test case contains a "while (it00++ != g.end())" which will cause undefined behavior at runtime (which in the reported case is an attempted unaligned access). The problem arises on the last iteration where the compiler is forced to increment an iterator that is already pointing to g.end(), which is undefined behavior.

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

              Created:
              Updated:
              Resolved:

                Connection: Intermediate to External PROD System
                EXTSYNC-1256 - C++ feature causes runtime failure ...
                SYNCHRONIZED
                • Last Sync Date: