<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56819>56819</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            control flow break with no warning due to infinite loop UB
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jnk0le
      </td>
    </tr>
</table>

<pre>
    Affected is (C++) clang 13.0.0 and onward, lower versions and gcc are just emitting infinite loops in this case.

https://godbolt.org/z/4WEs838h6

it seems to be doing 2 things 

1 - removing/optimizing out the infinite loop
2 - removing any code and function epilogue after the loop as if it was "unreachable"

It also suppresses warning of another UB in `foo3` being the implicit return from non void function (another control flow break of course)


Reasoning behind side effect free infinite loops UB [1] seems to be to allow optimization of infinite loops that cannot be proven to finish. Probably definition got too vague...

Previous hits by llvm implementation of this UB were just related to the 1st point e.g. rust-lang/rust/issues/28728 

[1] -https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1528.htm

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtU01vnDAQ_TVwGS3iO-yBQz5aqbeoUtWzMQM4MR5km10lv75jb9LuRpXAxnjezPOb54HGt_5-mlB6HEE5SMruMSkf4nMEqYWZoaiyPMtBmBHInIUdk_IRNJ3RwgmtU2Rc3JylBGERXnbnAVflvWK0MpMyyiMjaHO8BL9wISkcZkn-lOT3l3HxfnNJdZ-U3_mZaRxI-4zszKt3fuvf31xXdUt7DVIeHOLqwBMMCCOFimWoYGY-zFVkAQewuNKJdzgbbV6t6j2E0-4ZgLdEL6DyCsRHfANJI8azTruRnk8OuClN885_J8-ChEQBD4KPOgHzO4ugarkbi0IuYtDIq2tmPzwI7Qjcvm0WnUPHGGsitYmLEee08OshSJe0-URU8cTHDRGR-LppJbmURb9bA5OlFQxzO5G6Ysqt_UwmyXhLGibuIgxM7DWUkrRbx-yO1-wu408UjiKlAVnbEZxiITAah-shfm0z002ahyJpnm4axKPQoeiH_iIy49pf4H4Rni1imG-AbZZOaAI6RLklg2dLA2v5BiNGYEgzc7AngpPgfmTZjbueLZ4U7Q4W5R0Mb6D1aY3K4YrG_-URvcnk2dwfRraoRbgcXDyIXfCvjW3GDs_mDCyHHMItYU-Fb56Uczs6_ii7u7K7MeGnJIdbs5_P54w2NAfnxw_Hv3hZ8OQke4UD5qK-xPE4kgzZTdGUXbb49ZI6xb5om2NxLNuuSce-Go_VUaReeY39f_p9Vn5hk_y12rjH7tz0gYVId6v7L1eTkfuQSVp5EWT8mA7cpRf2w7UETdsVx3TpZVNXR5QiL2tRFG073LVVPk11107dVLd5qsWA2vUsEN8Og2eIKcJNaZ5S1Zd5WeZ3VV7UTVHWWdPU7V2Ty6orpmkc6qTOcRVKZ4FHUDC1faQ07LPjTa2cd_82hXNqNoixHOcXu1_I9i_mNdeYxsp9ZP4HbXCu_w">