This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Wuyin Lin, The C standard explicitly allows the address of the first element past the end of an array to be used in pointer arithmetic. You can check the C Programming Language, 2nd edition, for confirmation of this in section 5.4 on address arithmetic. It would lead to undefined behavior to actually dereference this element, but it is permitted to take its address and use that in comparisons, which is what is done in libsrc/putget.c. Nevertheless, it would probably avoid the warning from the IBM compiler if this were rewritten to replace const char *const end = &xfillp[sizeof(xfillp)]; with the equivalent const char *const end = xfillp + sizeof(xfillp); instead, although it might not be as clear what is going on. By the way, our version of xlc on AIX does not emit the warning you are seeing. Did you have to use some special compiler option(s) to produce more warnings? --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: MZX-901611 Department: Support netCDF Priority: Normal Status: Closed