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

gcc 8 reports bug: division ‘sizeof (int *) / sizeof (int)’ does not compute the number of array elements #4

Open
lacker opened this issue Jun 21, 2022 · 0 comments
Assignees

Comments

@lacker
Copy link

lacker commented Jun 21, 2022

hpguppi_coherent_bf_thread.c: In function ‘safe_close_all’:
hpguppi_coherent_bf_thread.c:57:29: error: division ‘sizeof (int *) / sizeof (int)’ does not compute the number of array elements [-Werror=sizeof-pointer-div]
   int pfd_size = sizeof(pfd)/sizeof(int);
                             ^
hpguppi_coherent_bf_thread.c:55:32: note: first ‘sizeof’ operand was declared here
 static int safe_close_all(int *pfd) {
                           ~~~~~^~~
cc1: all warnings being treated as errors

int pfd_size = sizeof(pfd)/sizeof(int);

gcc 8 throws a warning/error on this bit of code. I think it is correctly identifying an error here - this doesn't actually calculate the size of pfd, which I think will cause it to leave files open.

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

No branches or pull requests

2 participants