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

    <tr>
        <th>Summary</th>
        <td>
            [libc][math] `sqrt(-infinity)` not setting `errno == EMOD` or raising exceptions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc
      </td>
    </tr>

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

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

<pre>
    Following up on #61092, this case still remains.

## Problems:
The ISA-specific implementations aren't setting `errno == EDOM` on negative, non-zero numbers. 
The generic implementation and the `sqrt_80_bit_long_double` generic implementation do not set `EDOM` or raise `FE_INVALID`. 

## Potential fixes:
Fixes for the generic implementation seem straight forward. I can add a check that the argument is less than zero before the asm sqrt insn in the ISA-specific impls; I would guess the best way to do this is with FPBits to avoid changing FP flags/exceptions?

For the ISA-specific implementations, we could add a check for numbers less than zero before the assembly instruction.

Tagging @nickdesaulniers and @michaelrj-google.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2PnDgQ_TXmUuqWMTRDHzjMLEFqabMZaaO9towpoBJj97rMdGZ__cqksz1RNrmAsOvj1av30Mw0OcRGHJ7Eoc30Gmcfms5qN5CjrPfDa9N5a_2V3ATrBbwDoYoql0cl1G8QZ2IwmhE4krUQcNHkeC9kK-Tj7akKoQp4Dr63uLAobucfZ4TTn487vqChkQzQcrG4oIs6kncMOqAT6iECY4ypv6gkhuA8iKIVRQvv2g_vRSUTKIeTjvSCCZTzbvcPBg9uXXoMvId7wwkdhh96gXYDxBlTB_47xHMtzz3Fs_VuOg9-7S2mPj9JHjw4v6FM-f-BChA08Vaze3c-_fHX4--nVlTyG5zv2fERXSRtYaQveCepS18w-rDB-wkARlyAY9A0zTEFX3UY9nACox3oYQANZkbzGeKs41ZIh2lN-UAMFpnTjYONtB5HH_BrFC-Q6ABy7IDcdvjDylgUT3CCq1_tANP6tRpCjxzhql8h-sTQphRiuFKcoXt-osjpRr94GsDM2k1pw90zjFZPLFSHXwxeNiGIonvLWHcj41faSTK4IpgN01sGEpM3WfxycMalt69p8BhWk2p-p-mPetrwilI6Mp8HZL1aR6lqkpIo5UJm1mjDp93k_WRxnw1NMRyLo86wyR_yQslSqjybG6XG49HgocCqkqPEsarqXNW5UQaL43HMqFFSlbLMD3ktpZL7SuZ9qc1B1QVi-aBFKZPv7N7al2Xvw5QR84pNXT9UdWZ1j5Y3iytlqTdCqWT20KTwXb9OLEppiSPfC0SKdvstbAmHVhyeFh1ncWi_eUSoekduJEfxVahjkvzNBf_v1fcf2je2SCH3DWdrsM0c42UTvuqE6iaK89rvjV-E6hKs22t3Cf4TmihUtw2ZpLLN-W8AAAD__xIclHc">