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

Expression with large numbers optimized incorrectly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Medium Medium

      The attached source file is a complete single file program.  It has this line ...

      fxdLogX = -6 * (X - 5000) * (X - 5000) + 120040 * (X - 5000) - 1682360000;

      It appears two times in slightly different contexts.  The code generated for each appearance of this expression is quite different.  The results computed are unexpectedly different.  

      Build the program ...

      % cl6x -mv6500 -g -s -o1 main.c -z -o main.out -m main.map 
      <Linking>
      

      When it is executed ...

      Fail!
      x = 2000
      func_fail(x) = 439698000
      func_pass(x) = -419296000
      Assertion failed, (0), file main.c, line 66
      

      The value 2000 is used because it does not cause the expression to overflow.  The func_fail and func_pass lines should show the same value.  The Assertion line should not appear.

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

              Created:
              Updated: