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

incompatible-pointer-types-discards-qualifiers in mfhdf/libsrc/putget.c #623

Open
schwehr opened this issue Feb 26, 2024 · 1 comment
Open
Assignees
Labels
Component - C Library Core C library issues Component - netCDF netCDF interface and nc* command-line tools Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Improvement Improvements that don't add a new feature or functionality
Milestone

Comments

@schwehr
Copy link
Collaborator

schwehr commented Feb 26, 2024

This is with llvm from it's main branch about 2-3 weeks ago. From hdf4 at a6eec0d

I'm still seeing one compiler warning that is probably pretty easy to fix.

third_party/hdf4/mfhdf/libsrc/putget.c:1417:45: error: passing 'const void *' to parameter of type 'char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
 1417 |     return (NCvar1io(handle, varid, coords, value));
      |                                             ^~~~~
third_party/hdf4/mfhdf/libsrc/putget.c:1353:59: note: passing argument to parameter 'value' here
 1353 | NCvar1io(NC *handle, int varid, const long *coords, Void *value)
      | 
@derobins derobins added Component - C Library Core C library issues Component - netCDF netCDF interface and nc* command-line tools Type - Improvement Improvements that don't add a new feature or functionality Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. labels Feb 29, 2024
@derobins
Copy link
Member

Unfortunately, this will require significant rework to fix.

NCvar1io() will pass the value pointer to hdf_xdr_NCv1data(), then hdf_xdr_NCvdata(). That function can perform both encode and decode operations on the passed-in void pointer, so at some point there is going to be a const warning. Personally, I'd rather have a write buffer flagged as const until we have to strip it out vs. remove const entirely to make the compiler happy.

In HDF5, we use compiler-specific warning suppression to quiet those architectural "kinda const" situations. We'll probably bring those over to HDF4 in the next release, but we should also rework the stripped-down XDR layer that remains to have explicit encode and decode calls, which would go a long way towards proper const usage.

@derobins derobins added this to the 4.4.0 milestone Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - C Library Core C library issues Component - netCDF netCDF interface and nc* command-line tools Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

No branches or pull requests

2 participants