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

    <tr>
        <th>Summary</th>
        <td>
            No uninitialized  warning for member variable and getter
        </td>
    </tr>

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

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

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

<pre>
    ~~~~
#include <cstdio>

struct a{
    int i;
    int get_i() const {
 return i;
    }
    a() : i(get_i()){}
};


int main(){
 a instance = a();
    std::printf("%d", instance.i);
}
~~~~

clang does not generate any warning, even with optimizations enabled.

It generates a warning if `a() : i(get_i()){}` is changed to `a() : i(i){}`.

Example on godbolt, with comparison with GCC, which does generate a warning when optimizations are enabled

https://godbolt.org/z/6E43zroWj
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU82OmzAQfhpzGW1k7BDCgUM22VS99NpjZfAEZmvsyDa73Rzy7JXZ_LBRD5XQGOz5fuZDViFQZxFrVjyzYpepMfbO1wf8TT5rnP6oz-fzmfEd4xsmJNnWjBqByW0boibH5MvlcKoh-rGNoFj5_LkBAEA2AjH5sNNh_EVMrJmooHU2RLiDPMbR2wcQK3f3D3VBMrmBxDJjS0_5fOtOL1eaeU0eBkX2ArppKyAborJtmnJ3FfriJETN5IbJzdGTjYepQzBR6GnZ3ggWNEfeHM0SnWprlO1AOwxgXQrGolcRQdkPeFfeku0SK76hhXeKPbhjpIFOKpKzAdCqxqBezCm_32kCqCsL0AHYiv9XdisOFKDtle1QQ3T_AtK8_Yv-yx81HA2Cs9A53TgT0wST-dYNR-UpuMsw37bb6ayntv8M4R7Azfh7j_ZhbOXxOvpcuY_xGNLfEXsm9hfxhfMdE_sTE_vVy1KevPv5mula6kpWKsM6L3kheSXXRdbXyCtRHfJctkuNy7Ypy2atilzLtlpJuc4zqgUXS57nBa-45MVCas110ZSVQlEWYsmWHAdFZmHM25C0MwphxLpc56LKjGrQhOuF83VqemrGLrAlNxRiuMMiRYP1DwejJUuRlKETarjFcnAeBhwa9PCmPKUwQFmd7lZEn43e1A95UOzHZtG6gYl9krksT0fvXrGNTOwnq4GJ_eT2bwAAAP__pVo5ZQ">