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

Compiler emits the wrong constant when the input to __delay_cycles exceeds INT32_MAX

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Low Low

      The problem only occurs when building on Linux.

      The attached file.c contains these lines ...

      const uint32_t MAX_CYCLES_WITHOUT_ERROR = INT32_MAX;
      void main(void)
      {
        __delay_cycles(MAX_CYCLES_WITHOUT_ERROR);
        __delay_cycles(MAX_CYCLES_WITHOUT_ERROR+22);
      }
      

      Build it ...

      $ clpru -s file.c
      "file.asm", WARNING! at line 76: [W0001] Constant value out of range, will be
                                               truncated to 32 bits
                      LDI32    r0, 9223372035781033993
      
      No Assembly Errors, 1 Assembly Warning
      

      This line is associated with the second call to __delay_cycles. When built on Windows, the compiler emits this instead ...

              LDI32    r0, 1073741833
      

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

              Created:
              Updated: