Variable arguments (varargs) generates illegal code when passing structures

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Medium
    • Code Generation Tools
    • CODEGEN-10976
    • Hide
      C29_1.0.0.LTS
      C29_3.0.0.LTS*
      C29_2.0.0.STS
      C29_2.1.0.STS
      C29_2.2.0.LTS
      Show
      C29_1.0.0.LTS C29_3.0.0.LTS* C29_2.0.0.STS C29_2.1.0.STS C29_2.2.0.LTS
    • Hide
      C29_3.0.0.LTS*
      C29_1.0.2.LTS*
      C29_2.2.1.LTS*
      Show
      C29_3.0.0.LTS* C29_1.0.2.LTS* C29_2.2.1.LTS*
    • default

      Consider the following code:

      #include <stdarg.h>
      
      struct S { int x; };
      
      extern void use(int);
      
      void callee_s(int k, ...) {
        va_list ap;
        va_start(ap, k);
        struct S s = va_arg(ap, struct S);
        use(s.x);
      }
      
      void caller_s() {
        struct S s = { 7 };
        callee_s(2, s);
      } 

      The compiler will erroneously generate two loads for the initialization of 'struct S s' in callee_s, leading to a memory error.

            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-4801 - Variable arguments (varargs) genera...
                SYNCHRONIZED
                • Last Sync Date: