mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
101 stars 73 forks source link

asn_imax2INTEGER: warning: array subscript 0 is outside array bounds #102

Closed pespin closed 8 months ago

pespin commented 2 years ago

while building osmo-cbc [1] code with current mouse07410 vlm_master (24247e2813a7510ebabe6a9b6b6b29fffa0eb27b)

/root/tmp-pespin/git/osmo-cbc/src/sbcap/gen/INTEGER.c: In function ‘asn_imax2INTEGER’:
/root/tmp-pespin/git/osmo-cbc/src/sbcap/gen/INTEGER.c:364:22: warning: array subscript 0 is outside array bounds of ‘intmax_t[1]’ {aka ‘long long int[1]’} [-Warray-bounds]
  364 |  for(bp = buf, pend1 += add; p != pend1; p += add)
      |                ~~~~~~^~~~~~
/root/tmp-pespin/git/osmo-cbc/src/sbcap/gen/INTEGER.c:320:42: note: while referencing ‘value’
  320 | asn_imax2INTEGER(INTEGER_t *st, intmax_t value) {
      |

This happens when building on a 32bit system (raspbian 10, armv7l).

# gcc --version
gcc (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110

Using build flags CPPFLAGS="-ggdb3 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -std=gnu11 -Wall"

[1] https://gitea.osmocom.org/cellular-infrastructure/osmo-cbc/

mouse07410 commented 2 years ago

@pespin does the current master fix this problem? If not - do you have any idea what may be wrong?

pespin commented 2 years ago

@mouse07410 do you mean vlm_master of this same repo? I didn't see any change in that file (INTEGER.c) since I posted it, so the issue must be there already.

No idea what's wrong at first look sorry, that's why I posted it here.

mouse07410 commented 2 years ago

@pespin yes, vlm_master of this repo, it's the default branch, and the only branch that's maintained :).

Please try to figure what seems to be causing this crash.

pespin commented 2 years ago

Hi, note it is not a crash, it's just a gcc compilation warning I saw while compiling in that platform. I posted it here in case somebody wants to find out what's going on there.

mouse07410 commented 8 months ago

@pespin , can you confirm that the warning disappeared on your system? I'd like to close this issue.

And thanks to @BoskyWSMFN!

pespin commented 8 months ago

Hi, I no longer see any warning when compiling osmo-cbc with gcc version 13.2.1 20230801after having regenerated the files with as1nc from current vlm_master (12b8e555b971c745ea715cb247f39120fa15f7f0).