https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123915

            Bug ID: 123915
           Summary: [M68K][Fixed-Point] Compiler may generate wrong
                    overflow in conversion from 'double' to '_Accum'
           Product: gcc
           Version: 14.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: djipi.mari at gmail dot com
  Target Milestone: ---

No matter what, the conversion will generate warnings, by examples:

test.c:676:14: warning: overflow in conversion from 'double' to '_Accum'
changes value from '-6.8000006999999998e+4' to '6.3071993011474609375e+4'
[-Woverflow]
  676 |         j4 = -68000.007;
      |              ^
test.c:682:14: warning: overflow in conversion from 'double' to '_Accum'
changes value from '-9.9999990000000002e+5' to '-6.5536e+4' [-Woverflow]
  682 |         j4 = -999999.9;
      |              ^
test.c:685:14: warning: overflow in conversion from 'double' to '_Accum'
changes value from '9.9999990000000002e+5' to  6.5535999969482421875e+4'
[-Woverflow]
  685 |         j4 = 999999.9;
      |              ^~~~~~~~

In the first case, the overflow value can be wrong, such as:
_Accum j4
j4 = -68000.007;
Will have a positive value of 63071.993.

For the second case, the conversion value seems right:
j4 = -999999.9;
Will have a negative value of -65536.000

For the third case, the conversion value seems right:
_Accum j4
j4 = 999999.9;
Will have a positive value of 65535.999

Reply via email to