Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-8753

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Medium 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.

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

              Created:
              Updated:
              Resolved: