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

Unchecked function assigned to safe typedef #719

Open
kyleheadley opened this issue Oct 1, 2021 · 2 comments
Open

Unchecked function assigned to safe typedef #719

kyleheadley opened this issue Oct 1, 2021 · 2 comments
Labels
benchmark failure A bug causing a failure in our nightly benchmark tests function pointer typedef

Comments

@kyleheadley
Copy link
Member

In this simplification of a vsftpd error:

typedef void (*fp)(int *i); // given checked type

void simplefunc(int *i) {
  i = (int*)1; // unsafe - function will not be _Checked
}

void test(void) {
  fp func = simplefunc; // fail compilation: assign unchecked to checked
}

3C completes but clang won't accept the function pointer initialization in test. If simplefunc were checked, or even declared but undefined, clang would accept it. This may be another case for having an unchecked variant of a typedef (see #389).

@kyleheadley kyleheadley added typedef function pointer benchmark failure A bug causing a failure in our nightly benchmark tests labels Oct 1, 2021
@john-h-kastner
Copy link
Collaborator

Does this work if you explicitly take the address of simplefunc? I think this might be a Checked C compiler bug where it doesn't handle implicit conversion from function to function pointer correctly.

@kyleheadley
Copy link
Member Author

if I change the line to fp func = &simplefunc; then, yes it will compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark failure A bug causing a failure in our nightly benchmark tests function pointer typedef
Projects
None yet
Development

No branches or pull requests

2 participants