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

Undefined behaviour on shifts #122

Open
spth opened this issue Jul 24, 2024 · 0 comments
Open

Undefined behaviour on shifts #122

spth opened this issue Jul 24, 2024 · 0 comments

Comments

@spth
Copy link

spth commented Jul 24, 2024

Compiling this with SDCC yields warnings:

minimp3.h:379: warning 116: left shifting more than size of object changed to zero
minimp3.h:649: warning 116: left shifting more than size of object changed to zero

Looking at the code, there is indeed a problem:

s = g_deq_L12[ba*3 - 6 + b % 3]*(1 << 21 >> b/3);
…
y *= g_expfrac[e & 3]*(1 << 30 >> (e >> 2));

1 is an int, so on targets where int is less than 31 bits, the 1 << 30 most likely does not do what is intended here. I think changing both 1 to 1l should fix the 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

No branches or pull requests

1 participant