mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-30 16:10:44 +08:00
Chasing down implicit char cast which rounds a value to 0 when a negative value is cast to a different unsigned type.
This commit is contained in:
parent
bd92caa176
commit
8e4a8f4225
29
gdb.txt
29
gdb.txt
@ -1,7 +1,30 @@
|
||||
break util.c:960 if var_name[i][0] == 'c' && var_name[i][1] == 'r' && var_name[i][2] == '\0' && i == 6 && j == 1
|
||||
set breakpoint pending on
|
||||
|
||||
break test_put.c:3330 if var_name[i][0] == 'c' && var_name[i][1] == 'r' && var_name[i][2] == '\0'
|
||||
break test_write.c:737 if var_name[i][0] == 'c' && var_name[i][1] == 'r' && var_name[i][2] == '\0'
|
||||
break test_write.c:740 if i == 6
|
||||
|
||||
#-------------
|
||||
break test_nc_put_var1
|
||||
commands
|
||||
break util.c:968
|
||||
commands
|
||||
print ((signed char*)((ncio_px*)nc3->nciop->pvt)->bf_base + 9816)[0]
|
||||
end
|
||||
break util.c:970 if i == 6 && j == 0 && expect == -128
|
||||
break util.c:974
|
||||
break putget.c:10414
|
||||
commands
|
||||
print ((signed char*)((ncio_px*)nc3->nciop->pvt)->bf_base + 9816)[0]
|
||||
end
|
||||
|
||||
end
|
||||
#------------------
|
||||
|
||||
####
|
||||
# No. We know the problem is in reading, not writing.
|
||||
####
|
||||
|
||||
#break test_put.c:3330 if var_name[i][0] == 'c' && var_name[i][1] == 'r' && var_name[i][2] == '\0'
|
||||
#break test_write.c:737 if var_name[i][0] == 'c' && var_name[i][1] == 'r' && var_name[i][2] == '\0'
|
||||
|
||||
|
||||
#break util.c:960 if i == 6 && j == 0
|
||||
|
@ -687,7 +687,11 @@ done:
|
||||
pxp->bf_rflags |= rflags;
|
||||
pxp->bf_refcount++;
|
||||
|
||||
#ifdef CHAR_IS_SIGNED
|
||||
*vpp = (void *)((char *)pxp->bf_base + diff);
|
||||
#else
|
||||
*vpp = (void *)((signed char*)pxp->bf_base + diff);
|
||||
#endif
|
||||
return ENOERR;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "tests.h"
|
||||
#include <math.h>
|
||||
|
||||
void
|
||||
print_nok(int nok)
|
||||
{
|
||||
@ -303,10 +302,14 @@ int dbl2nc ( const double d, const nc_type datatype, void *p)
|
||||
*((signed char *) p) = r;
|
||||
break;
|
||||
case NC_CHAR:
|
||||
r = floor(0.5+d);
|
||||
if ( r < text_min || r > text_max ) return 2;
|
||||
*((char *) p) = r;
|
||||
break;
|
||||
r = floor(0.5+d);
|
||||
if ( r < text_min || r > text_max ) return 2;
|
||||
#ifdef CHAR_IS_SIGNED
|
||||
*((char *) p) = r;
|
||||
#else
|
||||
*((signed char*) p) = r;
|
||||
#endif
|
||||
break;
|
||||
case NC_SHORT:
|
||||
r = floor(0.5+d);
|
||||
if ( r < short_min || r > short_max ) return 2;
|
||||
@ -957,8 +960,8 @@ check_vars(int ncid)
|
||||
error("error in toMixedBase 2");
|
||||
expect = hash( var_type[i], var_rank[i], index );
|
||||
if (isChar) {
|
||||
err = nc_get_var1_text(ncid, i, index, &text);
|
||||
IF (err)
|
||||
err = nc_get_var1_text(ncid, i, index, &text);
|
||||
IF (err)
|
||||
error("nc_get_var1_text: %s", nc_strerror(err));
|
||||
IF (text != expect) {
|
||||
error("Var %s value read 0x%02x not that expected 0x%02x ",
|
||||
|
Loading…
Reference in New Issue
Block a user