發表文章

目前顯示的是 4月, 2015的文章

avoid implicit type conversion in ternary operation

failed case on llvm 3.6 uint   convert_uint_sat_rte (float x); int  main() {   float x1;   x1 = 9223373136366403584.000000f;    uint  r1 =  convert_uint_sat_rte (x1);    printf ("%x\n", r1); } uint   convert_uint_sat_rte (float x) {   return bigger(x) ? 0xffffffff: (small(x) ? 0 :  rintf (x)); } clang 3.6 + O2 get blow IR define i32 @ convert_uint_sat_rte (float %x) #0 { entry:   %call = call  fastcc  i32 @bigger(float %x)   % tobool  =  icmp  ne i32 %call, 0    br  i1 % tobool , label %cond.end6, label % cond.false cond.false :                                       ;  preds  = %entry   %call1 = call  fastcc ...

gcc 4.9 default open -fdelete-null-pointer-checks

#include int foo(int *a, int size){ memset (a, 0, size); if (a != NULL)    return 1; else    return 0; } this function always return 1 gcc 4.9 default opens -fdelete-null-pointer-checks but memset's first funtion parameters is "nonull attribute", so else section will be removed