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

    <tr>
        <th>Summary</th>
        <td>
            [clang] gcc compatibility regarding constexpr evaluation of __builtin_* for math functions
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          chris-durand
      </td>
    </tr>
</table>

<pre>
    gcc allows to evaluate all math built-ins in a `constexpr` context. libstdc++ even provides extended `constexpr` math functions, [like `constexpr std::sin`](https://gcc.godbolt.org/z/xaqKz9qEn). That library extension is in violation of the C++ standard but libstdc++ developers [decided to keep it](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49813) nevertheless.

The feature is especially useful in embedded code bases for small devices to do complex pre-computations at compile-time.

Could it be acceptable to make most math builtins available from a `constexpr` context in clang? The change should not cause any non-conformities since functions in libc++ are still not `constexpr`. Users who heavily rely on the constexpr behaviour could define their own functions using the built-ins and more easily migrate from gcc to clang.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VD1z4zgM_TV0g7FGpmxFLlzk49xcu1dnKBKScKFILwEqcX79DRXfZJOdbWwNSQDvPTzAMNMYEE_q8KAOTxuTZYrpZKdEvHU5meA2fXTX02gtGO_jK4NEwMX4bATLEcxGJugzedlSYKAABlRb2xhY8O2SVFuDjUHwTSrw1LM4q_SD0g-ACwa4pLiQQwZ8EwwO3W_Ra4UhBysUAyv9COrw4OkFv7wEFqeae9XcMwXV1urwpHQ3iVy4HOuz0ufR2mqMro9eqphGpc_vSp_fzM-_348__wpKHyv4MRkpOJNJ1w9MTDEArdQWit4UGBAHkAnh8UaFxQRnkoM-yzeWDhf08YKJC26HlgpJifCCeAGSPwIN-Qayz-M7eW-UPvMUX5_7PFZ2JNWcyanmaX_sdo3SRwi4YJIJPTJXqn5S9f3H748JYUAjOWEhgnxBS8b7K2TGIftCDeceXUFmo0PoDSPDEBPwXLrscCGLa_ddBBvni8c3uCTclu8sqygMRtY78rgVmvELiMeYvQMS6BGMtXgR03ssGWfzgjBHll_MVLxkFkN-fTSkOP_ZVwW-9SaMqjlD4WonE0YEntaSIQpYkxnBhCuEGLY2hiGmmYSQgSlY_PRXSeap_797JiGwkPdrmm8AKviHS19fpwgTmoX8FRL6K8SwuuPTnD1OZqGYE9gVk8OBApZHlCC-hl_qZ6YwruGfU2WCgzkmBDRcisw0pjKAqy5lOCV-KFBt3Klxx-ZoNnjatd1ut2-btttMp75pO3MchkFrtO3h7mCO1nW2bnZdN7hut6GTrnVT73f17q5u667a7bv2Tg93x37fDQfXq32NsyFfeb_MxZobYs54anW9P2686dHzukm0DvgK66XSuiyWdCox2z6PrPa1Jxb-zCIkfl1BHz08PK2Mio-MUE-epKg6muSKMJ-a3tbQbRqfn2--eVb6fnXu172xycmfvk0ZyZT7ysZZ6XOBc_vbXlL8F60ofV5JsNLnleR_AQAA___xeMZm">