Closed cspiegel closed 1 year ago
Thanks! The GetNibbleTrackLength()
function is modified from the original Ciderpress source, but I was apparently too careless when cobbling together the version used in ScottFree. I guess the original has other code in place to handle the -1 path.
As the function currently only either returns kTrackLenNib525
(6656) or asserts, it is pretty redundant, so I think the best solution is to remove it altogether. I'll make a new pull request over at the garglk repository.
OK, merged into garglk. Thank you!
Fixed in d61b0a1. Thanks for the repor!
When building Gargoyle with the new Scott Adams interpreter, the following occurs:
What's happening is that gcc thinks that "size" can be -1 in some cases, which gets passed as
SIZE_MAX
tomemcpy()
. The reason it thinks so is this function:It sees the -1 as a possible return, and follows that to the copy. The
assert(0)
is meant to avoid that possibility, but Gargoyle uses CMake, and when CMake builds in release mode, it sets theNDEBUG
macro, which disablesassert()
. DisablingNASSERT
in CMake is hacky and I'd prefer not to work around things that way.The reason
NDEBUG
disables assertions is thatassert()
is meant to capture "impossible" states, ones which should only happen during development and thus ones that will only be caught when release mode isn't turned on. If that's the case here, if all the asserts will truly never trigger, then I'd ask that thereturn -1
here be replaced withabort()
, to appease gcc.On the other hand, if the assertions should be called, I'd request that they be replaced with non-conditional calls to a custom assert. Something like the following would work, I think:
If you'd rather not make any of these changes, I'll just locally modify Gargoyle to call
abort()
in the path that causes gcc to complain.