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

Add warning for pointer arithmetic on pointers to void #759

Closed
ehaas opened this issue Aug 27, 2024 · 0 comments · Fixed by #776
Closed

Add warning for pointer arithmetic on pointers to void #759

ehaas opened this issue Aug 27, 2024 · 0 comments · Fixed by #776
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ehaas
Copy link
Collaborator

ehaas commented Aug 27, 2024

#include <stddef.h>
ptrdiff_t foo(void *a, void *b) {
    return b - a;
}
~ % gcc -Wgnu-pointer-arith test.c
test.c:3:14: warning: arithmetic on pointers to void is a GNU extension [-Wgnu-pointer-arith]
    return b - a;
           ~ ^ ~

The check can go after this line:

if (!a.ty.eql(b.ty, p.comp, false)) try p.errStr(.incompatible_pointers, tok, try p.typePairStr(a.ty, b.ty));

@ehaas ehaas added enhancement New feature or request good first issue Good for newcomers labels Aug 27, 2024
@Vexu Vexu closed this as completed in #776 Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant