linux - Inconsistent value returned by function -
when call function default_ratio_check(...), confusing value.
const int comp_read_compress = 1; const int comp_write_compress = 0; const int comp_trace_use_default_ratio = 2; double comp_default_ratio = 0.20; compress_struct* compress_global; double default_ratio_check( char** s, int i) { if( s == null ){ if(comp_trace_use_default_ratio ) { return comp_default_ratio; } } if( comp_read_compress || comp_write_compress ){ if(comp_trace_use_default_ratio ) { comp_default_ratio = atof( s[i] ); return comp_default_ratio; } } return 0; }
i assign result double type "ratio".
ratio = default_ratio_check( (char**)0, 0 );
the value assigned ratio 2.0, value of comp_trace_use_default_ratio instead of comp_default_ratio. change value of comp_trace_use_default_ratio,correspondingly, returned value ratio followed. have use gdb step function, , find works correctly. return value wrong after default_ratio_check() returned. helping. gcc version 5.2.1 20151010; ubuntu 15.10
Comments
Post a Comment