Skip to content

Undefined behaviour on shifts #122

@spth

Description

@spth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions