You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix undefined behavior caused by mismatched parameter types
When using 'make ENABLE_UBSAN=1 check CC=clang', the following error is
observed:
src/emulate.c:1110:13: runtime error: call to function do_fuse1 through pointer to incorrect function type 'bool (*)(struct riscv_internal *, const struct rv_insn *, unsigned long, unsigned int)'
/home/eleanor/code/rv32emu/src/emulate.c:415: note: do_fuse1 defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/emulate.c:1110:13
After fixing the first error with 'do_fuse1', similar errors were
observed for other functions like 'do_fuse2', 'do_fuse3', 'do_fuse4',
and 'do_jal'. The root cause was type mismatches in parameter
declarations, where 'rv_insn_t *' was used instead of the expected
'const rv_insn_t *'. Since 'do_jal' was generated by the 'RVOP'
macro in 'rv32emu_template.c', the macro was also corrected.
These changes resolve the UBSAN errors and align all function pointers
and implementations.
0 commit comments