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

Some variadic functions rely on undefined behavior #224

Open
nemequ opened this issue Feb 24, 2017 · 0 comments
Open

Some variadic functions rely on undefined behavior #224

nemequ opened this issue Feb 24, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@nemequ
Copy link
Member

nemequ commented Feb 24, 2017

clang 3.9+ picks up some potential undefined behavior I wasn't aware of: EXP58-CPP

Basically, anything subject to promotion can't be the last non-variadic argument in a variadic function. It's unlikely to be a problem, but technically enums aren't allowed. Need to make an API change to fix this, just not sure what the best option is yet…

Relevant functions are

SquashStream* squash_codec_create_stream (SquashCodec* codec, SquashStreamType stream_type, ...);
SquashStream* squash_stream_new (SquashCodec* codec, SquashStreamType stream_type, ...);

Possibly others, I haven't done a full check. One option would be reversing the stream_type and codec arguments, but that doesn't fit with the rest of the API. Changing SquashStreamType to an int would ruin -Wswitch-enum. Maybe drop SquashStreamType in favor of a bool…

@nemequ nemequ added the bug label Feb 24, 2017
@nemequ nemequ added this to the 0.8 milestone Feb 24, 2017
@nemequ nemequ self-assigned this Feb 24, 2017
@nemequ nemequ changed the title Some variadic functions exhibit undefined behavior Some variadic functions rely on undefined behavior Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant