• Milad Fa's avatar
    PPC/S390 [simulator] Use bit_cast instead of reinterpret_cast · dfe7aca1
    Milad Fa authored
    The following bit casting method using reinterpret_cast
    has undefined behaviour:
    ```
    int a = 1;
    float b = *reinterpret_cast<float*>(&a);
    ```
    Above breaks the strict aliasing rule which indicates:
    > dereferencing pointers to objects of different types will
    never refer to the same memory location.
    
    More information can be found under src/base/macros.h.
    
    `bit_cast` here is implemented with `memcpy` behind the scenes.
    C++20 will have this feature included by default.
    
    Change-Id: I69ffdbeba6db64e24b268d838ea1d863fcd9121d
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2889331Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
    Commit-Queue: Milad Fa <mfarazma@redhat.com>
    Cr-Commit-Position: refs/heads/master@{#74513}
    dfe7aca1
simulator-ppc.cc 167 KB