How to trigger warning: 'di' is used uninitialized here

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

Consider the following silly c++ code (*), it compiles nicely using
g++ 13.2 no warnings using either:

% g++  -c -O2 -Wall -Wextra alt.cxx

or

% g++  -c -O0 -Wall -Wextra alt.cxx

Is it possible to trigger a warning for this code (maybe I missed some
gcc options) ?

Thanks !


(*)
% cat alt.cxx
#include <cstdlib>
struct d {
  long cj[sizeof(long)];
};
long cl(d b) { return b.cj[0]; }
void k() {
    d di;
    long actual = cl(di);
    if (actual == 0)
      std::exit(42);
}

-- 
Mathieu



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux