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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] Invalid fixit from cppcoreguidelines-init-variables in the presence of goto
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          chrchr-github
      </td>
    </tr>
</table>

<pre>
    ~~~c++
void g(int);
int f(int i) {
    if (i == -1)
        goto end;
    int x;
 if (i > 1)
        x = 1;
    else
        x = 0;
    g(x);
end:
 return 0;
}
~~~
~~~
<source>:5:9: warning: variable 'x' is not initialized [cppcoreguidelines-init-variables]
    5 |     int x;
      | ^
      |           = 0
~~~
Applying the fix results in
~~~
<source>:4:9: error: cannot jump from this goto statement to its label [clang-diagnostic-error]
    4 |         goto end;
      | ^
<source>:5:9: note: jump bypasses variable initialization
    5 |     int x{};
      |         ^
~~~
https://godbolt.org/z/j43cdjYvo
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVM2u4yoMfhpnY-UogTCZLLJop6fSfYS7JIEmrihEQHrbWfTZr0j6M9PR0aCqAcxn-_NnkCHQYLVuQWxB7DI5x9H5th99P_p8oDjOXdY5dW1vt1sPbJt-xebsSOEA7DvZCKwBnjbJRjyse0jAGoQ6bSMi0gGTAYHvgO8wLxNoNaUxuOhQW7X6WQA24uW-fIE_8Q14SR6xfOG0CfoPe_Gyp5wvz4yXkJtk8jrO3j5OQr2DYnO73Z7_wH8EN_teA_8EvhHANw3wDf4nvSU7pOlZepKd0QisvgCrkQJaF5EsRZKGfmqFILb9NPXO62EmpQ1ZHfJ0IH-gA4jdPVeBUP_A92osIxlAfP62fo2V8yP1zTSZK9kB46jxQBf0OswmBiT7Fb3qQU9773ya9NImLsf5NOHBuxPGkcKqW4gy6pO2EaNDigGN7LRZqBpph1yRHKwLkfp8dfckWP2W959N8CvPrwSwLur0XTLrrpMMQYeXFs_iy0jOflHYepsEfwv7LOYSfi3TGOMUUsewPbD94FTnTPxwfgC2_wlsf6x4r47_nl2mWq4a3shMt2UtOBcl_yaysT2oRvFGCSkK1pe9_qZ41TRdUfLvHdOFzqhlBRNFzaqyKFglPrRSspGKVbLuWF1WUBX6JMl8GHM-pdgZhTDrthQFb-psKX5YrjNjqwCR1BUYS9fbtwmVd_MQoCoMhRhefiJFszwEv8DEDv-xZ2lIpdahuIr_tx5Gsku3TV4HbXuN7rDIm83etG9FXJ6Yj96dgO1TKvdPPnl31H0Etl_4BWD7O8Vzy_4PAAD__y4GY8Y">