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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] `switch` statement: an enum value does not always have to equal one of the enumerators.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    In this [compiler explorer experiment](https://godbolt.org/z/4ro4ncTzo), GCC warns "warning: control reaches end of non-void function", while Clang does not. 

In this instance, GCC is making an important point: the function `f` cannot assume that its parameter of enum type has a value that is one of the enumerator values, because this enumerator has a a fixed underlying type (the `: int` in the enum declaration) and the standard says that in that case, any integer of that underlying type may be casted to this enum type: https://eel.is/c++draft/expr.static.cast#9

Currently, GCC always warns regardless of having a specified underlying type in the enum declaration ; Clang never warns.  If my understanding of the spec is correct then the reachability of the end of the function (and therefore, the rationale for generating a warning) is when there is no specified underlying type.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VMGSozgM_RpzUTUFJiThwKGTVLbmvj8gbAGeNTZrm6QzX78lSKZnp6ZzCAbbT096T8IYzeCIWlGfRH3JcEmjD233HZXvss7rR_vNQRpNBFGflJ9mYykAfczWh21BwUzkkqgvQh7HlOYoqnchr0JeB687b1PuwyDk9YeQ113wO6f-_uGFbIQ8w1_nM9wxuAhCSl4YN4jqHZR3KXgLgVCNFIGcBt-D8-7t5o2GfnEqGe-ElAxzH40lOFt0A2hPEZxPOYjiIor37f-VhXExoVP0Cm4iTPiPcQOgAzPNPiR0CWZvXGIiaaSfwUDsi17sC1DonE-AMS4TQRoxgUkRZgw4UaLAVMktE6THTDBiBIQb2uV1NoJ3xIcYnQ9SwOTDdiYytY4ULpE2zr-c2LAQevNBGhanKdgHs18jCXlkRLEvmDpnsC_AuJ9hQJOyGHCrXAPo9LrHJdEYNER8xCdHtz0VxrVW6B4MSMOW3br3e_gJH9ARX0mkIflP9us-c_q_P4hsbqKQVyXkSciTDtgn_v4xhzwmTEbljCZk1fwq5nkJgVyyj5eKaO_MfHNSoAGDthQjMx3xtqoLcSZlevOHsn1RIRDV6ekpRzcKG3wO8K2H6bGhrJVjoKeYHIT1VT4EUom_beCrkbEz1qTHp_L6tfy0mDw-VQnU-7DWfr2_UkJL0PsAAzk2xJbYq21kw5Hvz4iB-M35r_POM91WuqkazKgtD1VZ8G-fja2kQmPddEVVN31xVHW9w-a407Q_NGW3rzLTykLuyrI4lAdZFLtcyn0ti25fllRo6g9iV9CExubW3ibu_8zEuFBblnW1qzOLHdm4Dh0pFZeYG7m-ZKHlC2_dMkSxK6yJKX5CJJPsOqlWUUR9YafHu0lqZKOzYWgdRdU7d_Oq59Z2r5nwMsqIN2KD0r8L2j83Y8yzJdj2t4Fm0rh0ufKTkFfm9Xy8zcF_J8XeXfNkTz9TvbXyvwAAAP__RrjUtA">