<div>I would like to request a feature, __builtin_undefined()<br></div><div>This would serve multiple purposes, it would be similar to __builtin_unreachable, but can be used to specify that the behavior upon reaching it it undefined (not necessarily that it can't be reached.)<br></div><div>For example, in pseudo code "T my_array<T>::operator[](size_t n) { if (n >= this->internal_size) __builtin_undefined(); ... }"<br></div><div><br></div><div>So this would indicate that a user has invoked undefined behavior, and -fsanitize=undefined would trap this behavior, and additionally, when debugging is disabled, the compiler could use __builtin_undefined() as an optimization hint.<br></div><div><br></div><div>I like to distinguish my proposed __builtin_undefined() from __builtin_unreachable() in that __builtin_unreachable() should really be unreachable. (Even if the user e.g. uses an invalid input index?) (i.e., it should indicate a bug in the code that uses __builtin_unreachable() rather than in the calling code)<br></div><div><br></div><div>I recognize that the distinction is probably not substantial, but being able to explicitly specify certain behavior as undefined might prove useful when developing libraries as compilers develop more advanced optimizations.<br></div><div class="protonmail_signature_block"><div class="protonmail_signature_block-user"><div>--<br></div><div>Ryan Nicholl<br></div><div>(678)-358-7765<br></div></div><div><br></div><div class="protonmail_signature_block-proton">Sent with <a href="https://protonmail.com">ProtonMail</a> Secure Email.<br></div></div><div><br></div>