https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124063

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>*(const double *)

This deference requires 8byte alignment due to the alignment requirements of C.

If you want a type which has a lower alignment you can do:

typedef double unaligned_double __attribute__((aligned(1)));

And then use that:
```
uint32_t test(const void *pAddr, unaligned_double *plfValue)
{
    if ((NULL == pAddr) || (NULL == plfValue)) {
        return (0 | 7);
    }

    *plfValue = (double)(*(const unaligned_double *)pAddr);
    return (0 | 0);
}
```


Also note even in GCC 7, it required an alignment of 64bits:
```
(insn 21 20 22 4 (set (reg:DF 113 [ _4 ])
        (mem:DF (reg/v/f:SI 115 [ pAddr ]) [1 MEM[(const double *)pAddr_7(D)]+0
S8 A64])) "/app/example.cpp":8 -1
     (nil))
(insn 22 21 6 4 (set (mem:DF (reg/v/f:SI 116 [ plfValue ]) [1 *plfValue_8(D)+0
S8 A64])
        (reg:DF 113 [ _4 ])) "/app/example.cpp":8 -1
     (nil))
```

It just didn't use those instructions then.

Reply via email to