Skip to content

Conversation

@shravanrn
Copy link
Collaborator

@shravanrn shravanrn commented Apr 24, 2025

Enum types in variadic functions aren't guaranteed to work. This is because enums for variadics undergo default argument promotion (promotion to int), and thus the user of va_arg should always get the argument as an int. Thus enums in varargs function would break on any compiler whose underlying representation is not an int (e.g., when using gcc's -fshort-enums flag)

https://stackoverflow.com/questions/73278375/do-enum-types-undergo-default-argument-promotion
https://stackoverflow.com/questions/24580503/error-when-pass-enum-in-a-function-with-variable-arguments/24580800#24580800

This pattern is used in the get_func_type function emitted as part of wasm2c modules. This PR changes this API to always use int for the var args.

@shravanrn shravanrn requested review from keithw and sbc100 April 24, 2025 04:04
@shravanrn shravanrn force-pushed the get_func_type_enum branch from aa4225f to 298243f Compare April 24, 2025 04:12
@shravanrn shravanrn force-pushed the get_func_type_enum branch from 298243f to 762f9a3 Compare April 24, 2025 18:58
@shravanrn shravanrn enabled auto-merge (rebase) April 24, 2025 18:59
@shravanrn shravanrn merged commit 879af11 into WebAssembly:main Apr 24, 2025
18 checks passed
@shravanrn shravanrn deleted the get_func_type_enum branch April 24, 2025 21:23
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 this pull request may close these issues.

2 participants