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

Internal error when passing a temporary array of objects

    XMLWordPrintable

Details

    • Bug
    • Status: Accepted
    • Medium
    • Resolution: Unresolved
    • Code Generation Tools
    • CODEGEN-4298
    • Hide
      ARM_18.1.0.LTS
      C2000_22.6.0.LTS
      ARM_18.12.0.LTS
      C2000_21.6.0.LTS
      ARM_20.2.0.LTS
      C2000_20.2.0.LTS
      Show
      ARM_18.1.0.LTS C2000_22.6.0.LTS ARM_18.12.0.LTS C2000_21.6.0.LTS ARM_20.2.0.LTS C2000_20.2.0.LTS
    • Hide
      The following example code exhibits an internal compiler error caused by passing a temporary C array as an argument to a function taking an rvalue reference to an array:

      struct S {
          int m;
          S(int i=1) : m(i) {}
          operator int() { return m; }
          int operator +(const S& r) { return m+r.m; }
      };

      int f00(S (&&r)[3]) { return r[0] + r[1] + r[2]; }

      int main(void) {
              int g;
              S a(97), b(2), c(1);
              g = f00({a, b, c});
      }
      Show
      The following example code exhibits an internal compiler error caused by passing a temporary C array as an argument to a function taking an rvalue reference to an array: struct S {     int m;     S(int i=1) : m(i) {}     operator int() { return m; }     int operator +(const S& r) { return m+r.m; } }; int f00(S (&&r)[3]) { return r[0] + r[1] + r[2]; } int main(void) {         int g;         S a(97), b(2), c(1);         g = f00({a, b, c}); }

    Description

      The following code will crash the compiler during the code generator's decomposition pass:

      #include <initializer_list>
      #include <stdio.h>
      struct S {
      int m;
      S(int i=1) : m {}
      operator int()

      { return m; }

      int operator +(const S& r)

      { return m+r.m; }

      };
      int f00(S (&&r)[3])

      { return r[0] + r[1] + r[2]; }

      int main(void)
      {
      int x, g;
      x = 100;
      g = f00(

      {97, 2 }

      );
      if (g != x)
      printf("Got %d instead of %d", g, x);
      return (2);
      }
      when compiled with:

      > armcl -mv7m4 --abi=eabi -g --cpp_default -c test.cpp
      Removing the debug option will make the decomp crash go away.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: