<div dir="ltr"><div><div>Hello fellas,<br></div>  Recently i was working on bug, which is simplified as follow.<br><br></div><div><br></div><div>===================================================================================================================<br></div>Code:<br><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Fira Mono;font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(0,0,255)">#include</span><span style="color:rgb(0,0,0)"><iostream></span></div><br><div><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> thisShallError(</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> b[</span><span style="color:rgb(9,136,90)">10</span><span style="color:rgb(0,0,0)">]){</span></div><div><span style="color:rgb(0,0,0)">    </span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> gaurdTop = </span><span style="color:rgb(48,48,192)">0xF0F0</span><span style="color:rgb(0,0,0)">;</span></div><div><span style="color:rgb(0,0,0)">    </span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> c[</span><span style="color:rgb(9,136,90)">16</span><span style="color:rgb(0,0,0)">] = {</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">};</span></div><div><span style="color:rgb(0,0,0)">    </span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> gaurdDown[</span><span style="color:rgb(9,136,90)">16</span><span style="color:rgb(0,0,0)">];</span></div><div><span style="color:rgb(0,0,0)">    gaurdDown[</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">] = </span><span style="color:rgb(48,48,192)">0x0F0F</span><span style="color:rgb(0,0,0)">;</span></div><div><span style="color:rgb(0,0,0)">    </span><span style="color:rgb(0,0,255)">return</span><span style="color:rgb(0,0,0)"> c[</span><span style="color:rgb(9,136,90)">16</span><span style="color:rgb(0,0,0)">] | b[</span><span style="color:rgb(9,136,90)">11</span><span style="color:rgb(0,0,0)">];</span></div><div><span style="color:rgb(0,0,0)">}</span></div><br><div><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> main(){</span></div><div><span style="color:rgb(0,0,0)">    </span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)">  mb[</span><span style="color:rgb(9,136,90)">32</span><span style="color:rgb(0,0,0)">]={</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">};</span></div><div><span style="color:rgb(0,0,0)">    mb[</span><span style="color:rgb(9,136,90)">11</span><span style="color:rgb(0,0,0)">] = </span><span style="color:rgb(48,48,192)">0xF0F0</span><span style="color:rgb(0,0,0)">;</span></div><div><span style="color:rgb(0,0,0)">    std::cout<<std::hex << thisShallError(mb);</span></div><div><span style="color:rgb(0,0,0)">    </span><span style="color:rgb(0,0,255)">return</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">;</span></div><div><span style="color:rgb(0,0,0)">}</span></div></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Fira Mono;font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Fira Mono;font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Fira Mono;font-weight:normal;font-size:14px;line-height:19px;white-space:pre">Warning:</div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Fira Mono;font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><div class="gmail-lm_items" style="width:839px;height:909px"><div class="gmail-lm_item_container" style="width:839px;height:909px"><div class="gmail-lm_content" style="width:839px;height:909px"><pre class="gmail-content" style="font-size:10pt"><div><a href="https://godbolt.org/#">4 : <source>:4:9: warning: unused variable 'gaurdTop' [-Wunused-variable]</a></div><div>    int gaurdTop = 0xF0F0;</div><div>        ^</div><div><a href="https://godbolt.org/#">8 : <source>:8:12: warning: array index 16 is past the end of the array (which contains 16 elements) [-Warray-bounds]</a></div><div>    return c[16] | b[11];</div><div>           ^ ~~</div><div><a href="https://godbolt.org/#">5 : <source>:5:5: note: array 'c' declared here</a></div><div>    int c[16] = {0};</div><div>    ^</div><div>2 warnings generated.</div><div>Compiler exited with result code 0</div><div><br></div></pre><div>===============================================================================</div><div><br></div><div><br></div><div>Things to note here.</div><div>1. variable b's size is know at compile time and i was expecting error just like c [third warning]</div><div>2. thisShallError accepts size of array as 10 but it is clearly declared with 32. Should we do something.  [Given fact that Array will decay to pointer but sanitizer may warn, if possible]</div><div><br></div><div>I want to confirm if this is bug or not,sanitizer has no false positive rule scenario??, will happy to patch it myself :)</div><div><br></div><div>Thanks</div><div>Mahesh</div><div><br></div></div></div></div></div></div></div>