scarybeasts / beebjit

A very fast BBC Micro emulator.
Other
132 stars 15 forks source link

Compile failure with gcc 11.1 #30

Closed SteveFosdick closed 3 years ago

SteveFosdick commented 3 years ago

When compiling beebjit, using build_opt.sh, compilation stops with the following from gcc:

n function ‘asm_tables_init’,
    inlined from ‘asm_tables_init’ at asm/asm_tables.c:11:1,
    inlined from ‘asm_abi_init’ at asm/asm_abi.c:31:3,
    inlined from ‘cpu_driver_alloc’ at cpu_driver.c:171:3:
asm/asm_tables.c:34:14: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
   34 |     *p_dst++ = val;
      |              ^
asm/asm_tables.c:54:14: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
   54 |     *p_dst++ = val;
      |              ^
asm/asm_tables.c:63:12: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
   63 |   *p_dst++ = 0;
      |            ^
asm/asm_tables.c:64:12: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
   64 |   *p_dst++ = 0x40;
      |            ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: gcc returned 1 exit status

This is on commit 0e576642e05ee3d4361faeb69327d29de00068c2

SteveFosdick commented 3 years ago

And, if I temporarily remove -Werror, there are some more, similar, warnings:

In function ‘jit_opcode_make_uop1’,
    inlined from ‘jit_opcode_find_replace2.constprop’ at jit_opcode.c:34:3:
jit_opcode.c:41:10: warning: ‘memset’ writing 12 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
   41 |   (void) memset(p_uop, '\0', sizeof(struct jit_uop));
      |          ^
In function ‘jit_opcode_make_uop1’,
    inlined from ‘jit_opcode_find_replace1’ at jit_opcode.c:16:3,
    inlined from ‘jit_compiler_try_make_dynamic_opcode’ at jit_compiler.c:1652:7,
    inlined from ‘jit_compiler_check_dynamics’ at jit_compiler.c:2003:7,
    inlined from ‘jit_compiler_compile_block’ at jit_compiler.c:2386:3,
    inlined from ‘jit_compile’ at jit.c:566:25:
jit_opcode.c:41:10: warning: ‘memset’ writing 12 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
   41 |   (void) memset(p_uop, '\0', sizeof(struct jit_uop));
      |          ^
In function ‘jit_opcode_make_uop1’,
    inlined from ‘jit_compiler_try_make_dynamic_opcode’ at jit_compiler.c:1782:5,
    inlined from ‘jit_compiler_check_dynamics’ at jit_compiler.c:2003:7,
    inlined from ‘jit_compiler_compile_block’ at jit_compiler.c:2386:3,
    inlined from ‘jit_compile’ at jit.c:566:25:
jit_opcode.c:41:10: warning: ‘memset’ writing 12 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
   41 |   (void) memset(p_uop, '\0', sizeof(struct jit_uop));
      |          ^
In function ‘jit_opcode_make_uop1’,
    inlined from ‘jit_opcode_find_replace1’ at jit_opcode.c:16:3,
    inlined from ‘jit_optimizer_optimize’ at jit_optimizer.c:1054:7,
    inlined from ‘jit_compiler_compile_block’ at jit_compiler.c:2407:17,
    inlined from ‘jit_compile’ at jit.c:566:25:
jit_opcode.c:41:10: warning: ‘memset’ writing 12 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
   41 |   (void) memset(p_uop, '\0', sizeof(struct jit_uop));
      |          ^
scarybeasts commented 3 years ago

Thanks! Looks like gcc 11.1 is doing some fancy propagation of statically determinable pointer properties. I like it!

I'll find something with gcc 11.1 and address these.