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

[ffi] Varargs should give an error on uint8, int8, uint16, int16 and float #56058

Open
dcharkes opened this issue Jun 20, 2024 · 5 comments
Open
Assignees
Labels
area-native-interop Used for native interop related issues, including FFI. good first issue A good starting issue for contributors (issues with this label will appear in /contribute) library-ffi P3 A lower priority bug or feature request

Comments

@dcharkes
Copy link
Contributor

Passing 8 bit or 16 bit ints in varargs is undefined behavior.

Clang will alert us:

Second argument to 'va_arg' is of promotable type 'uint16_t' (aka 'unsigned short'); this va_arg has undefined behavior because arguments will be promoted to 'int'clang(-Wvarargs)

But we allow this in dart:ffi, leading to undefined behavior.

We should consider adding an error message.

Discovered on:

@dcharkes dcharkes added library-ffi area-native-interop Used for native interop related issues, including FFI. good first issue A good starting issue for contributors (issues with this label will appear in /contribute) P3 A lower priority bug or feature request labels Jun 20, 2024
@dcharkes dcharkes changed the title [ffi] Varargs should give an error on uint8, int8, uint16, and int16 [ffi] Varargs should give an error on uint8, int8, uint16, int16 and float Jun 20, 2024
@vaishnavi-2901
Copy link

hey
can work on it, please assign this task to me

@dcharkes
Copy link
Contributor Author

hey can work on it, please assign this task to me

Hi @vaishnavi-2901! That's great!

Please start with https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md

A PR for this issue will involve adding error messages both to the CFE (the compiler used when doing dart ...) and analyzer (used in the IDE for giving error messages).

Some pointers to point you in the right direction:

It's probably easiest to

  1. First convert the test
  2. Then make an analyzer PR
  3. And then in a third PR try to tackle the CFE.

@trivedikavya
Copy link

hey sir can i work on it ..?

@dcharkes
Copy link
Contributor Author

@vaishnavi-2901 are you still working on this?

@trivedikavya
Copy link

Dear respected sir let she work and let me also work on it. as I am beginning the open source contribution first you will check the request of both and then you will see what to do
I have one Question sir just tell me in which file I have to contribute .

vijayindalkar added a commit to vijayindalkar/sdk that referenced this issue Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-native-interop Used for native interop related issues, including FFI. good first issue A good starting issue for contributors (issues with this label will appear in /contribute) library-ffi P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants