Pay caution when using gcc -O3 option

Pay caution when using gcc -O3 option

  1. Alignment

    ‘cell_t’ is packed 512 byte structure and ‘skey_t’ is 8 byte unsigned type. In this function, it breaks 4 byte alignment by adding 3 to ‘c’ and casting it as ‘skey_t’ type pointer. It does not generate error with -g -O0 option, but you may see silent SIGSEGV (without core dumped message) when you compile it with -O3. The error will be gone if you add 4 instead of 3.
    (Linux version: 3.5.0-51-generic #77~precise1-Ubuntu SMP Thu Jun 5 00:48:28 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux, GCC version: gcc-4.6.real (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3)


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.