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

[netCDF #FMK-929748]: checking NC_ERANGE for type conversion from schar to uchar



Hello,

Thank you for this and the other bug reports; I'm taking a look at them now.  
You are correct that this should return an NC_ERANGE error.  I believe this is 
related to issue 304 in our JIRA system 
(https://bugtracking.unidata.ucar.edu/browse/NCF-304).  Once this issue is 
corrected, this test should fail properly.

Thanks again for your bug reports!

-Ward

> I notice a comment at line 336 in file nc_test/tst_atts3.c.
> 
> 336      /* Shouldn't this get an NC_ERANGE error for storing -128 into an 
> unsigned char?  Possible bug ... */
> 337      if (nc_get_att_uchar(ncid, NC_GLOBAL, ATT_SCHAR_NAME, uchar_in)) ERR;
> 
> The test runs without errors on this line. But shouldn't it return NC_ERANGE?
> 
> nc_get_att_uchar() traces down to ncx_getn_schar_uchar() in file libsrc/ncx.c
> at line 2201. I can see the function does not check for negative values in 
> *xpp,
> a signed char, which should cause the out of range error for an unsigned char 
> type.
> 
> Is this supposed to be a correct behavior?
> 
> (I can see the same for ncx_getn_int_uint() when X_SIZEOF_INT == SIZEOF_INT)
> 
> Wei-keng
> 
> 

Ticket Details
===================
Ticket ID: FMK-929748
Department: Support netCDF
Priority: Normal
Status: Closed