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

Keith Packard noreply at github.com
Sat Feb 16 12:52:57 PST 2019

  Branch: refs/heads/master
  Home:   https://github.com/keith-packard/snek
  Commit: e8a1a5f69b9587b7420c98d84687b33552da9a15
  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