Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"conversion may change the value [-Werror=conversion]" compilation errors on MCST lcc compiler #52

Open
r-a-sattarov opened this issue Oct 21, 2020 · 2 comments · May be fixed by #72
Open

Comments

@r-a-sattarov
Copy link

When compiling TinySoundFont library as part of OpenGothic project (https://github.com/Try/OpenGothic), I get the following compilation errors on the MCST lcc compiler:

lcc: "/root/dev/r-a-sattarov/OpenGothic/lib/TinySoundFont/tsf.h", line 829: error #2463:
conversion may change the value [-Werror=conversion]
samplesLeft = *fontSampleCount = chunkSmpl->size / sizeof(short);

lcc: "/root/dev/r-a-sattarov/OpenGothic/lib/TinySoundFont/tsf.h", line 835: error #2463:
conversion may change the value [-Werror=conversion]
stream->read(stream->data, sampleBuffer, samplesToRead * sizeof(short));

lcc: "/root/dev/r-a-sattarov/OpenGothic/lib/TinySoundFont/tsf.h", line 1483: error #2463:
conversion may change the value [-Werror=conversion]
int channelSamples = (f->outputmode == TSF_MONO ? 1 : 2) * samples, floatBufferSize = channelSamples * sizeof(float);

log: TinySoundFont-OpenGothic_lcc_compile_err.log

original issue Try/OpenGothic#91

@ell1e
Copy link
Contributor

ell1e commented Nov 18, 2021

Isn't a signed to unsigned conversion on assignment relatively standard to do implicitly like that? Of course if one involved value is negative that's bad, but I don't really see that potential issue here. So I'm personally wondering if the best way to proceed would be to just suggest to not make use of that warning. (Note: just a random contributor, so my opinion isn't too relevant. But maybe someone finds it interesting)

@schellingb
Copy link
Owner

I'm usually on the mindset that libraries should be as friendly as possible in regards to compiler warnings. That usually means no warnings on GCC/clang with -Wall -Wpedantic, as well as no warnings on MSVC with /W4.

Now, non-default warnings like this -Wconversion (or MSVC's /Wall) can be a bit annoying for sure... For tsf.h we get 45 conversion warnings which probably all are irrelevant and just need some cast to be silenced. Sometimes this can lead to better code (i.e. finding multiple variables which shouldn't be different types) but also some cases need more thought than one might expect (i.e. figuring out if it's theoretically possible for something to ever be negative). I would happily merge a patch for sure :-)

@petershh petershh linked a pull request Jan 25, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants