rgbds icon indicating copy to clipboard operation
rgbds copied to clipboard

Check for consistency of fixed-point precision in operations

Open ISSOtm opened this issue 1 year ago • 22 comments

Goal: print a warning when doing any of these

  • [ ] 1.0 + 1
  • [ ] 1.0 * 2.0
  • [ ] MUL(1.0q8, 2.0q8, 16)
    • [ ] Check that we still warn if q8 and/or , 16 are omitted (with the appropriate OPT Q setting, of course).
  • [ ] 1.0q8 + 2.0q16
  • [ ] Warn if any fixed-point value is passed to RGBLINK, as it lacks precision info (and I don't think it's worth adding, fixed-point ops are clearly meant to be kept at compile time).

We may want that warning to have levels, since e.g. someone may be intentionally multiplying fixed-point numbers together and correctly dealing with the resulting precision change.

Bikeshed points:

  • How many levels to have?
  • What level to assign to each case?
  • Which levels should be default, assigned to -Wall, assigned to -Wextra?

(Originally brought up in https://github.com/gbdev/rgbds/pull/1455#discussion_r1706841243)

ISSOtm avatar Aug 07 '24 13:08 ISSOtm