output_ihex.c
It buffers the character and then increments a file-local (declared static outside any function - so "global" for any code in the file but not actually exported) addr value.
When it actually outputs, it does the check - checking against that addr value in write_data_record() - but that addr value is now actually one /after/ the address of the byte we last stuffed into the buffer, and if the check weren't there /we might not ever get to the point where we would try to buffer something for that address/.
Edit: Or to state it another way, it is treating addr as “the next address I can modify data at” except when it does the test - there it is treating it as “the highest address I have modified”.
It appears to work fine in the (very very small number) of cases I tried after I changed
Code:
if (ihex_fmt == I8HEX && addr > UINT16_MAX)
output_error(11, addr);
if (ihex_fmt == I16HEX && addr > MEBIBYTE)
output_error(11, addr);
to:
Code:
if (ihex_fmt == I8HEX && addr > UINT16_MAX+1)
output_error(11, addr);
if (ihex_fmt == I16HEX && addr > MEBIBYTE+1)
output_error(11, addr);
So I think, yeah, this is definitely an ihex output module bug.
More edit: I don’t really trust this to be the only bug in the little bit I’ve looked at the code, I’d be interested in seeing what Paganini might get even with this fix given the wildly large address complained about in that case.
Edit one more time: I keep thinking that it may well be a better fix to move the original test to just before addr is incremented. It’ll test more but possibly fail faster.