[Bug c++/61292] auto keyword to reference generates wrong alignment move (causing runtime segfault)

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 28 16:09:54 GMT 2021


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-07-28
             Status|UNCONFIRMED                 |NEW
            Summary|auto keyword to vector      |auto keyword to reference
                   |reference generates wrong   |generates wrong alignment
                   |alignment move (causing     |move (causing runtime
                   |runtime segfault)           |segfault)
     Ever confirmed|0                           |1
           Keywords|                            |wrong-code

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is unrelated to vector_size attribute even.
Take:
typedef float float32x4_t;
typedef float __attribute__( ( aligned(1) ) ) float32x4a4_t;


void add11(float32x4a4_t * x, float y, float32x4_t v) {
   auto & k1 = *(float32x4a4_t*)(x);
   auto & k2 = *(float32x4a4_t*)(x);
   k1 +=v;
   k2 += k1+v;
}

void add98(float32x4a4_t * x, float y, float32x4_t v) {
   float32x4a4_t & k1 = *(float32x4a4_t*)(x);
   float32x4a4_t & k2 = *(float32x4a4_t*)(x);
   k1 +=v;
   k2 += k1+v;
}
------ CUT -----
With aarch64 at -O2 -mstrict-align, we get float loads/stores for add11 but
correctly get the byte loads/stores for add98.

Note I notice clang gets this wrong too.


More information about the Gcc-bugs mailing list