Disable GCC “may be used uninitialized” on a particular variable

前端 未结 5 563
故里飘歌
故里飘歌 2021-02-01 03:09

I\'m getting this warning on a stack variable:

warning: object.member may be used uninitialized in this function

In this case I do not wish to

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 03:44

    GCC differentiates between uninitalised and self initalized, e.g. compiling:

    int main() {
       int i = i;
       return i;
    }
    

    With gcc -Wall -Wextra gives no warnings, unless you explicitly added -Winit-self as well, yet it gets completely optimized out by my quick testing.

提交回复
热议问题