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

Arrays of Byte Peripherals or types aligned larger than their size should generate error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-1671
    • Hide
      C2000_15.12.0.LTS
       C2000_16.3.0.STS
      Show
      C2000_15.12.0.LTS  C2000_16.3.0.STS
    • Hide
      C2000_15.12.4.LTS
       C2000_16.9.1.LTS
      Show
      C2000_15.12.4.LTS  C2000_16.9.1.LTS
    • Do not attempt to create an array of byte peripheral objects.
    • Hide
      The C language guarantees that the size of an array is equal to the size of each element times the number of elements. Because we double the alignment of byte peripheral data types but do not change the size, this does not hold true. There would be padding in the array, which is not allowed by the standard.
      Underneath the hood, we use the aligned GCC attribute to change the alignment for byte peripherals. On GCC, if you try to make an array of elements whose alignment is larger than its size (see example code below), you get the following error:
         "9:1: error: alignment of array elements is greater than element size"

      However, our parser doesn’t generate an error. Instead, it just reduces the alignment of the element size silently and makes an array.
      We need to generate an error and document that this is not allowed, both for byte peripherals and the aligned GCC attribute.
      Show
      The C language guarantees that the size of an array is equal to the size of each element times the number of elements. Because we double the alignment of byte peripheral data types but do not change the size, this does not hold true. There would be padding in the array, which is not allowed by the standard. Underneath the hood, we use the aligned GCC attribute to change the alignment for byte peripherals. On GCC, if you try to make an array of elements whose alignment is larger than its size (see example code below), you get the following error:    "9:1: error: alignment of array elements is greater than element size" However, our parser doesn’t generate an error. Instead, it just reduces the alignment of the element size silently and makes an array. We need to generate an error and document that this is not allowed, both for byte peripherals and the aligned GCC attribute.

      Arrays of Byte Peripherals or types aligned larger than their size should generate error

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

              Created:
              Updated:
              Resolved: