<div dir="ltr"><div>I'm not sure if this is undefined behavior or not and it may be discussed before or not. I was testing some random code snippets to try "-fsanitize=undefined" but in this example:<br></div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:20px;line-height:27px;white-space:pre"><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(206,145,120)"><iostream></span></div><br><div><span style="color:rgb(86,156,214)">char</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">func</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">a</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">b</span><span style="color:rgb(212,212,212)">) {</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">sum</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(156,220,254)">a</span><span style="color:rgb(212,212,212)">+</span><span style="color:rgb(156,220,254)">b</span><span style="color:rgb(212,212,212)">;</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(197,134,192)">return</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">sum</span><span style="color:rgb(212,212,212)"> ;</span></div><div><span style="color:rgb(212,212,212)">}</span></div><br><div><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">main</span><span style="color:rgb(212,212,212)">() {</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">n</span><span style="color:rgb(212,212,212)">;</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(86,156,214)">char</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">s</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(220,220,170)">func</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(181,206,168)">100</span><span style="color:rgb(212,212,212)">,</span><span style="color:rgb(181,206,168)">100</span><span style="color:rgb(212,212,212)">);</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">t</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(220,220,170)">func</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(181,206,168)">100</span><span style="color:rgb(212,212,212)">,</span><span style="color:rgb(181,206,168)">100</span><span style="color:rgb(212,212,212)">);</span></div><div><span style="color:rgb(212,212,212)">   </span><span style="color:rgb(78,201,176)">std</span><span style="color:rgb(212,212,212)">::</span><span style="color:rgb(156,220,254)">cout</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)"><<</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(206,145,120)">"hello"</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)"><<</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">s</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)"><<</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">t</span><span style="color:rgb(212,212,212)">;</span></div><div><span style="color:rgb(212,212,212)">  </span><span style="color:rgb(197,134,192)">return</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)">;</span></div><br><div><span style="color:rgb(212,212,212)">}</span></div><div><span style="color:rgb(212,212,212)"><br></span></div></div></div><div>I was expecting some kind of undefined behavior here because of some overflowing the char return type with integer return type. But "-fsanitize=undefined" is not able to catch this . And I got the output this : hello�-56 <br></div><div>Kinda weird for me . <br></div></div>