發表文章

目前顯示的是 2015的文章

sizeof trap

see more detail in jesrv blog http://blog.linux.org.tw/~jserv/archives/001876.html A class with an empty sequence of members and base class objects is an empty class. Complete objects and member subobjects of an empty class type shall have nonzero size. #include <stdio.h> int main()                                                                                         {     printf("%d, %d\n", sizeof('J'), sizeof(char));     return 0; } gcc output is $ gcc -o sizeof sizeof.c $ ./sizeof 4, 1 but g++ output is $ g++ -o sizeof sizeof.c  $ ./sizeof 1, 1 because 'j' default is integer in c, is char in c++

good example for gdb reverse execution

https://www.youtube.com/watch?v=PorfLSr3DDI&t=9m5s https://sourceware.org/gdb/onlinedocs/gdb/Process-Record-and-Replay.html record https://sourceware.org/gdb/onlinedocs/gdb/Reverse-Execution.html#Reverse-Execution reverse-continue reverse-stepi

被討厭的勇氣 自我啟發之父阿德勒的教導

重點在於並不是因為發生了這些事就一定有什麼樣的結果, 我們是藉著"賦予過去的經驗什麼意義"來決定自己的一生. 人生不是別人給的,是我們自己選擇的. 決定要怎麼生活的, 是我們自己 問題不是在"經歷什麼事", 而是"如何解釋它", "如何運用它" 無論之前你的人生發生過什麼事, 那對你將來要怎麼過日子一點影響也沒有. 決定你人生的, 是活在當下的自己 我們無法改變客觀的事實, 卻可以隨意更改主觀的解釋 憤怒不過是一種為了達到目的而採取的手段,只是個工具而已 老是想要尋求別人的認同,在意他人的評價,到最後你過的就是別人的人生 完全只在乎"別人是如何看我"的這種生活方式,其實正是以自我為中心,只關心"我"的生活型態  ==>  你都沒想到 因為你只想到你自己

Strength and Power of Generalized Algorithm in Compiler Technologies

cite:  https://www.linkedin.com/today/post/article/strength-power-generalized-algorithm-compiler-ajit-agarwal?trk=seokp_posts_primary_cluster_res_title (need to login)     - Post order Traversal    - Reverse Post Order Traversal     - DFS Search and BFS Search.     - Topological Sorting Algorithms.  Following mention the strength and Power of the above Algorithms in the Compiler Technologies.      - Copy Propagation in SSA. The Copy propagation requires the traversal of SSA either in post order or reverse post order to get the USE and DEF. Post order traversal uses to traverse the use of SSA variables before Def in order to perform copy propagation. Reverse post order to traverse Def before use.     - Loop Induction Variables requires to form a Strongly connected component between Load/Computation with plus/multiple in form of induction/Store. The traversal of SSA graph can ...

Undefined, unspecified and implementation-defined behavior

http://stackoverflow.com/questions/2397984/ undefined -unspecified-and-implementation-defined-behavior Undefined  behavior The effect of attempting to modify a string literal is  undefined .  accessing an array beyond its bounds,  dereferencing the null pointer accessing objects after their lifetime ended   writing  allegedly clever expressions  like  i++ + ++i . Use of an uninitialized variable Signed integer overflow: Oversized Shift Amounts Dereferences of Wild Pointers and Out of Bounds Array Accesses: Dereferencing a NULL Pointer Violating Type Rules:  It is  undefined  behavior to cast an int* to a float* and dereference it    ==> dereferencing a pointer that aliases another of an  incompatible type  is  undefined  behavior. WHAT IS STRICT ALIASING? Strict aliasing is an assumption, made by the C (or C++) compiler, that dereferencing pointers to objects o...

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