[Snek] [keith-packard/snek] 9f6629: Disable -Warray-bounds when accessing _snek_mems

Keith Packard noreply at github.com
Sat Feb 16 12:48:45 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/keith-packard/snek
  Commit: 9f66295c48fa6ec8fc67a3858f715d69bc89e0d7
      https://github.com/keith-packard/snek/commit/9f66295c48fa6ec8fc67a3858f715d69bc89e0d7
  Author: Keith Packard <keithp at keithp.com>
  Date:   2019-02-16 (Sat, 16 Feb 2019)

  Changed paths:
    M posix/Makefile
    M snek-code.c
    M snek-memory.c
    M snek.defs
    M snek.h

  Log Message:
  -----------
  Disable -Warray-bounds when accessing _snek_mems

Because snek_builtin is type 0, this array would need an unused entry
were it indexed directly by type. Instead, it's indexed by type -
1. To avoid actually doing that computation at runtime, we do
(&_snek_mems[-1])[type], which makes the linker compute the base
address and then indexing by type 'just works'. However, the compiler
is not happy with the -1 index, generating -Warray-bounds warnings
when optimized. Suppress that warnings around this usage by placing
the usage in a static inline, instead of a macro.

Signed-off-by: Keith Packard <keithp at keithp.com>




More information about the Snek mailing list