Skip to content

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

@lacker

Description

@lacker
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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions