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

64bit set shift count overflow #827

Closed
ayfomin opened this issue Dec 17, 2020 · 1 comment · Fixed by #829
Closed

64bit set shift count overflow #827

ayfomin opened this issue Dec 17, 2020 · 1 comment · Fixed by #829

Comments

@ayfomin
Copy link

ayfomin commented Dec 17, 2020

When we use set type in a scheme with uint64 encoding type:

<set name="FlagsSet" encodingType="uint64">
    <choice name="Bit0" description="Bit 0">0</choice>
    <choice name="Bit35" description="Bit 35">35</choice>
</set>

sbe-all generates CPP code like this:

static bool bit35(const std::uint64_t bits)
{                                           
    return (bits & (1u << 35u)) != 0;
}

which causes warning in gcc:

FlagsSet.h:255:31: warning: left shift count >= width of type [-Wshift-count-overflow]
         return (bits & (1u << 35u)) != 0;

Here is the value of right operand - 35u is greater to the number of bits in the left operand 1u - 32 bits.

Could somebody help to fix it, please?

ex.zip

@mjpt777
Copy link
Contributor

mjpt777 commented Dec 17, 2020

Thanks for the report, we are a bit backlogged with other work at present. We can offer commercial support to those who need quick turn around on fixes. [email protected].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants