Set of array elements assigned with compound literals are not assigned with gcc-9.2 compiler

Nagaraju Mekala
Mon Mar 30 12:55:06 GMT 2020

Hello All,

Need help in resolving the below error:

The below code fails to assign values to a pointer variable with
gcc-9.2 compiler, same code works with gcc-8.2 compiler.


{0x0, 0x15, 0x0, 0x0, 0x34, 0x0, 0x35, 0x11, 0x15}

#define  BUS_SPEED 9

int temp_func()

  u32 *a;
  if (<cond>)
     abc = (u32 [BUS_SPEED]) FACE_DELAYS;


Note: The above code is just a sample of original testcase

The error is due change in  build_compound_literal function of gcc
(gcc/c/c-decl.c). Addition of below pushdecl() is causing the error.

 else if (current_function_decl && !current_scope->parm_flag)
    pushdecl (decl);

In GCC-8.2 we don't have above code, and it is generating memcpy as
expected, but in GCC-9.2 it is not generating Memcpy.

Actual Disassembly code between gcc-8.2 and gcc-9.2 for reference

8031578: 97ffdd44 bl 8028a88 <abc>
803157c: d2800482 mov x2, #0x24 // #36
8031580: 34001420 cbz w0, 8031804 <a1+0x304>
8031584: aa1403e1 mov x1, x20
8031588: 9102e3e0 add x0, sp, #0xb8
803158c: 9400f508 bl 806e9ac <memcpy>
8031590: 9102e3f5 add x21, sp, #0xb8
8031594: d2800482 mov x2, #0x24 // #36
8031598: 8b020281 add x1, x20, x2
803159c: 910243f4 add x20, sp, #0x90
80315a0: 910243e0 add x0, sp, #0x90
80315a4: 9400f502 bl 806e9ac <memcpy>
80315a8: 394146e0 ldrb w0, x23, #81

8031504: 97ffdd43 bl 8028a10 <abc>
8031508: 34001340 cbz w0, 8031770 <a1+0x2dc>
803150c: 910243f4 add x20, sp, #0x90
8031510: 9102e3f5 add x21, sp, #0xb8
8031514: 394146e0 ldrb w0, x23, #81

any help is much appreciated.


More information about the Gcc-help mailing list