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

Compiler fails to handle bare \r as a line separator

    XMLWordPrintable

Details

    • Bug
    • Status: Fixed
    • High
    • Resolution: Fixed
    • Code Generation Tools
    • CODEGEN-10058
    • Show
      https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1103378/tms320f280025-compiler-issue
    • Hide
      C7000_1.4.0.LTS
      C2000_22.6.0.LTS
      C6000_8.3.0
      MSP430_20.2.0.LTS
      C7000_2.1.0.LTS
      MSP430_21.6.0.LTS
      C2000_21.6.0.LTS
      ARM_20.2.0.LTS
      C2000_20.2.0.LTS
      Show
      C7000_1.4.0.LTS C2000_22.6.0.LTS C6000_8.3.0 MSP430_20.2.0.LTS C7000_2.1.0.LTS MSP430_21.6.0.LTS C2000_21.6.0.LTS ARM_20.2.0.LTS C2000_20.2.0.LTS
    • Hide
      ARM_20.2.7.LTS
      C7000_2.1.2.LTS
      C2000_20.2.7.LTS
      C2000_22.6.1.LTS
      MSP430_21.6.1.LTS
      C6000_8.3.13
      C7000_1.4.3.LTS
      C2000_21.6.1.LTS
      MSP430_20.2.7.LTS
      Show
      ARM_20.2.7.LTS C7000_2.1.2.LTS C2000_20.2.7.LTS C2000_22.6.1.LTS MSP430_21.6.1.LTS C6000_8.3.13 C7000_1.4.3.LTS C2000_21.6.1.LTS MSP430_20.2.7.LTS
    • default
    • Insert a carriage return \n or \r\n before the affected line of code.

    Description

      The parser for the TI compiler treats stand alone carriage return \r as white space.

      If a line of code (function call, expression, etc) following a line with
      comments ending in \r, then the line of code will be treated as comments.

      For below example, the function call two() is treated as comments as continued from the comments at end of the previous line.

      void one(), two();

      void line_ending_test()

      { one(); // this line ends with only \r two(); }

      More details
      --------------
      The attached source uses Windows text file line endings \r \n. Except one line has been intentionally changed to end only with \r. Even viewing this file is odd, because it depends on how the viewer software handles the case of a bare \r character. Here is a character by character dump using the utility od ...

      % od -An -c -w10 line_ending_test.c
         v   o   i   d       o   n   e   (   )
         ,       t   w   o   (   )   ;  \r  \n
        \r  \n   v   o   i   d       l   i   n
         e   _   e   n   d   i   n   g   _   t
         e   s   t   (   )  \r  \n   {  \r  \n
                     o   n   e   (   )   ;
         /   /       t   h   i   s       l   i
         n   e       e   n   d   s       w   i
         t   h       o   n   l   y       \   r
        \r               t   w   o   (   )   ;
        \r  \n   }  \r  \n
      

      Notice how every line ends with the sequence \r \n, except for the one with the comment: // this line ends with only \r . The TI proprietary compilers, including cl2000, view the bare \r character like a space or tab. It does not cause the line to end. Thus, the call to the function two() is commented out. Every other compiler I tried, including tiarmclang, views the bare \r as a line separator. Thus, the call to the function two() is not commented out. This is easily verified by viewing the assembly code generated by the compiler. I loaded this into compiler explorer, and tried many compilers. https://godbolt.org/z/Tfa7hTPad . Every one I tried generates a call to the function two().

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: