[Home]

Summary:ASTERISK-23556: Compilation warning for invert.c (array subscript is above array bounds)
Reporter:Marcello Ceschia (marcelloceschia)Labels:patch
Date Opened:2014-03-28 04:04:08Date Closed:2017-10-24 14:26:59
Priority:TrivialRegression?
Status:Closed/CompleteComponents:Codecs/codec_lpc10 Core/BuildSystem
Versions:11.22.0 13.8.2 Frequency of
Occurrence
Related
Issues:
Environment:gcc (SUSE Linux) 4.8.1 20130909 [gcc-4_8-branch revision 202388]Attachments:( 0) LPC-10_since_GCC_4_8_1.patch
Description:{code}
  [CC] invert.c -> invert.o
invert.c: In function ‘invert_’:
invert.c:167:24: warning: array subscript is above array bounds [-Warray-bounds]
     rc[j] -= rc[k] * v[j + k * 10 - 11];
{code}
Comments:By: Rusty Newton (rnewton) 2014-04-07 13:47:55.763-0500

Thank you for taking the time to report this bug and helping to make Asterisk better. Unfortunately, we cannot work on this bug because your description did not include enough information. You may find it helpful to read the Asterisk Issue Guidelines http://www.asterisk.org/developers/bug-guidelines. We would be grateful if you would then provide a more complete description of the problem. At a minimum, we need:

1. the specific steps or actions you took that caused you to encounter the problem,
2. the behavior you expected, and
3. the behavior you actually encountered (in as much detail as possible).

This likely includes output from the console with debug level logging, a SIP trace (if this is SIP related), and configuration information such as dialplan (e.g. extensions.conf) and channel configuration (e.g. sip.conf). Thanks!



By: Rusty Newton (rnewton) 2014-04-07 13:48:29.827-0500

Looks like this is happening during compilation for you, but I can't reproduce. Can you tell us how to reproduce this?

By: Marcello Ceschia (marcelloceschia) 2014-04-07 14:29:02.680-0500

It is really simple to reproduce this issue:

gcc --version
gcc (SUSE Linux) 4.8.1 20130909 [gcc-4_8-branch revision 202388]

svn co -r 411441 http://svn.asterisk.org/svn/asterisk/branches/12 ast_12_temp
cd ast_12_temp/
./configure
make

and you will get this warning



By: Rusty Newton (rnewton) 2014-04-21 16:13:28.365-0500

I was able to reproduce on a system with later GCC version. My system had an older version. Thanks.

By: Lukas Hauser (luka5) 2015-05-05 12:24:09.231-0500

I was able to reproduce this with the current version 13.3.2 on ubuntu 14.04.

$ gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2


By: Alexander Traud (traud) 2016-04-28 09:19:25.956-0500

Because {{*order}} is 10 (always), the array subscript cannot be above the bounds. Anyway on Ubuntu 16.04 LTS (GCC 5.3.1-14ubuntu2), this warning is emitted (only) when COMPILE_DOUBLE is enabled. The attached patch avoids that warning message for me. Alternatively, you replace {{*order}} with {{10}}. Steps to reproduce on Ubuntu 16.04 LTS:
{noformat}sudo apt install libssl-dev libncurses-dev libnewt-dev libxml2-dev libsqlite3-dev uuid-dev libjansson-dev libblocksruntime-dev
wget downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar zxf ./asterisk-1*
cd ./asterisk-1*
./configure
make menuselect.makeopts
./menuselect/menuselect --enable DONT_OPTIMIZE
make{noformat}

By: Corey Farrell (coreyfarrell) 2017-10-23 16:12:35.464-0500

[~traud]: Do you want to post your patch for review?

I've reset the severity to trivial as I don't think this has any real effect on the binary produced.

By: Friendly Automation (friendly-automation) 2017-10-24 14:26:59.880-0500

Change 6896 merged by George Joseph:
lpc10: Avoid compiler warning when DONT_OPTIMIZE/COMPILE_DOUBLE.

[https://gerrit.asterisk.org/6896|https://gerrit.asterisk.org/6896]

By: Friendly Automation (friendly-automation) 2017-10-24 14:32:11.661-0500

Change 6897 merged by Jenkins2:
lpc10: Avoid compiler warning when DONT_OPTIMIZE/COMPILE_DOUBLE.

[https://gerrit.asterisk.org/6897|https://gerrit.asterisk.org/6897]

By: Friendly Automation (friendly-automation) 2017-10-24 15:00:46.918-0500

Change 6898 merged by Jenkins2:
lpc10: Avoid compiler warning when DONT_OPTIMIZE/COMPILE_DOUBLE.

[https://gerrit.asterisk.org/6898|https://gerrit.asterisk.org/6898]