[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #BIE-294861]: [netcdfgroup] as_double weaknesses



Hi Sjur,

> I've come across two apparent properties of the as_double() function in the 
> NetCDF C++ interface:
> 1: as_double() does not check for data_mode, and creashes if the file is in 
> definition mode
> 2: as_double() does not check for dimension limits, returning whatever is in 
> the calculated memory location.
> 
> Are these checks left out intentionally to save time, or would it be 
> advantageous to have them? Considering that the function allocates and 
> deallocates memory on the fly, the extra time to perform these checks should 
> not be dramatic.
> 
> NetCDF 4 on Windows, precompiled C interface dll.

Thanks for reporting this problem.  I assume you are reporting 
the problem with the old netCDF-3 C++ interface in the cxx/ source
directory rather than the experimental (and incomplete) netCDF-4 
interface in the cxx4/ source directtroy, but the problems may be in 
both.  A user is currently working on completing the cxx4/ interface 
and upgrading it to make use of more modern C++ idioms, exceptions, 
templates, and name spaces.

The C++ interface was designed so that     

  * No explicit nc_redef or nc_endef calls are needed for switching between 
    define and data modes. Whenever a mode switch is required, it happens 
    implicitly.

so if that's not working when as_double() is invoked, it's a bug.  Also 
as_double(n) should return a fill value when n is out of range, so that 
also looks like a bug.  We'll try to get them fixed before the next release.

Thanks for reporting the problems!

--Russ


Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: BIE-294861
Department: Support netCDF
Priority: Normal
Status: Closed