shorepine / amy

AMY - A high-performance fixed-point Music synthesizer librarY for microcontrollers
https://shorepine.github.io/amy/
MIT License
188 stars 11 forks source link

`bp_end_times` and `breakpoint_values` have array bounds issues #153

Closed bwhitman closed 1 month ago

bwhitman commented 1 month ago

I'm compiling AMY on a new compiler/arch (RISCV) and got this error:

/Users/bwhitman/outside/amy/src/envelope.c:136:22: error: array subscript -1 is below array bounds of 'uint32_t[8]' {aka 'long unsigned int[8]'} [-Werror=array-bounds=]
  136 |     t1 = bp_end_times[found];
      |          ~~~~~~~~~~~~^~~~~~~
/Users/bwhitman/outside/amy/src/envelope.c:65:14: note: while referencing 'bp_end_times'
   65 |     uint32_t bp_end_times[MAX_BREAKPOINTS];
      |              ^~~~~~~~~~~~
In file included from /Users/bwhitman/outside/amy/src/amy.h:125,
                 from /Users/bwhitman/outside/amy/src/envelope.c:4:
/Users/bwhitman/outside/amy/src/envelope.c:137:50: error: array subscript -1 is below array bounds of 'float[8]' [-Werror=array-bounds=]
  137 |     v1 = F2S(synth[osc].breakpoint_values[bp_set][found]);
/Users/bwhitman/outside/amy/src/amy_fixedpoint.h:153:26: note: in definition of macro 'F2S'
  153 | #define F2S(f) (SAMPLE)((f) * (float)(1 << S_FRAC_BITS))
      |                          ^
/Users/bwhitman/outside/amy/src/amy.h:329:11: note: while referencing 'breakpoint_values'
  329 |     float breakpoint_values[MAX_BREAKPOINT_SETS][MAX_BREAKPOINTS];
      |           ^~~~~~~~~~~~~~~~~