bergzand / NanoCBOR

CBOR library aimed at heavily constrained devices
Creative Commons Zero v1.0 Universal
47 stars 23 forks source link

Error with the waspmote-pro board #80

Open jdavid opened 2 years ago

jdavid commented 2 years ago

When using NanoCBOR with the waspmote-pro board (in RIOT), I get the following error:

$ BOARD=waspmote-pro make -C tests/pkg_nanocbor
make: Entering directory '/home/jdavid/sandboxes/UiO/RIOT/tests/pkg_nanocbor'
Building application "tests_pkg_nanocbor" for "waspmote-pro" with MCU "atmega1281".

"make" -C /home/jdavid/sandboxes/UiO/RIOT/pkg/nanocbor/ 
"make" -C /home/jdavid/sandboxes/UiO/RIOT/build/pkg/nanocbor/src -f /home/jdavid/sandboxes/UiO/RIOT/Makefile.base MODULE=nanocbor
/home/jdavid/sandboxes/UiO/RIOT/build/pkg/nanocbor/src/encoder.c: In function ‘nanocbor_fmt_double’:
/home/jdavid/sandboxes/UiO/RIOT/build/pkg/nanocbor/src/encoder.c:324:21: error: array subscript ‘uint64_t {aka long long unsigned int}[0]’ is partly outside array bounds of ‘double[1]’ [-Werror=array-bounds]
  324 |     uint16_t exp = (*unum >> DOUBLE_EXP_POS) & DOUBLE_EXP_MASK;
      |                     ^~~~~
/home/jdavid/sandboxes/UiO/RIOT/build/pkg/nanocbor/src/encoder.c:321:57: note: while referencing ‘num’
  321 | int nanocbor_fmt_double(nanocbor_encoder_t *enc, double num)
      |                                                  ~~~~~~~^~~
cc1: all warnings being treated as errors
make[2]: *** [/home/jdavid/sandboxes/UiO/RIOT/Makefile.base:146: /home/jdavid/sandboxes/UiO/RIOT/tests/pkg_nanocbor/bin/waspmote-pro/nanocbor/encoder.o] Error 1
make[1]: *** [Makefile:9: all] Error 2
make: *** [/home/jdavid/sandboxes/UiO/RIOT/tests/pkg_nanocbor/../../Makefile.include:802: pkg-build] Error 2
make: Leaving directory '/home/jdavid/sandboxes/UiO/RIOT/tests/pkg_nanocbor'

This may be related to issue #18

bergzand commented 2 years ago

Thanks for the bug report. That indeed looks like an issue related to the word size of the atmega. I'll look into it later this week and see if I can come up with a fix.