title: warning: array subscript is above array bounds [-Warray-bounds]
body: <p>I'm having a problem with the following piece of code throwing warnings and hoping you could help me:</p>
  
  <pre><code>   fprintf (fp, "%dd%d+%d ", pMobIndex-&gt;mana[DICE_NUMBER],
  </code></pre>
  
  <p><code>DICE_NUMBER</code> is defined in my header file as 0.</p>
  
  <p>Obviously, 0 is not exceeding the size of the array.</p>
  
  <p>The array is defined as.</p>
  
  <pre><code>   int               mana[2];
  </code></pre>
  
  <p>I have absolutely no idea why it would be doing this, as 0 is clearly within the bounds of the array.  Half of my engines code is throwing these array bound errors now, I've got about 30 of them, and <em>NONE</em> of them make sense to me.</p>
  
  <p>Here is the output from make:</p>
  
  <pre><code>  gcc -O3 -s -Wall -c -o obj/olc_save.o olc_save.c
  olc_save.c: In function 'save_mobile':
  olc_save.c:234:13: warning: array subscript is above array bounds [-Warray-bounds]
       fprintf (fp, "%dd%d+%d ", pMobIndex-&gt;mana[DICE_NUMBER],
           ^
  </code></pre>
  
  <p>it also happens:</p>
  
  <pre><code>db1.c: In function 'create_mobile':
  db1.c:2056:30: warning: array subscript is above array bounds [-Warray-bounds]
               + pMobIndex-&gt;mana[DICE_BONUS];
  </code></pre>
  
  <p>and </p>
  
  <pre><code>olc_act.c: In function 'medit_manadice':
  olc_act.c:6500:15: warning: array subscript is above array bounds [-Warray-bounds]
       pMob-&gt;mana[DICE_BONUS] = atoi (bonus);
  </code></pre>
  
  <p>The definition in my header file:</p>
  
  <pre><code>/* dice */
  #define DICE_NUMBER  0
  #define DICE_TYPE    1
  #define DICE_BONUS   2
  </code></pre>
  
  <p>I'm aware <code>DICE_BONUS</code> will be (realizing it only now) but I for the life of me cannot figure out why <code>DICE_NUMBER</code> is.</p>
  
  <p>D'oh.  The problem is that the third integer output there on the <code>fprintf</code> is <code>DICE_BONUS</code> but its on another line, I thought the compiler was warning me about <code>DICE_NUMBER</code>, it was warning me about BONUS.</p>