Hi Axel, thank you very much!, I think that checking would need us to rewrite all of our class definitions to include this type of initialization. In the other hand, I know valgrind, and I use it regularly, but I cannot use it on embedded platforms, as it really takes a lot of memory. I was looking for something like Mic--soft compilers have.. keeping uninitialized values with a known constant, and when the attribute/variable is accessed, and this constant is detected, a runtime exception is thrown... I know it's not a perfectmethod, but it's quite useful :-) 2010/10/6 Axel Freyn <axel-freyn@xxxxxx>: > Hi Miguel, > On Wed, Oct 06, 2010 at 09:23:39AM +0200, Miguel Angel wrote: >> I've been searching about possible *run-time* checks that can be >> used with GCC, and after a little bit of investigation I discovered >> about -fbounds-check, but no others... >> >> -fbounds-check only apply to Fortran compiles or they work on C/C++ too? >> >> does exist some kind of flag for testing on unitialized variables >> (during runtime), in my case some problems arise when somebody leaves >> an unintialized C++ class attribute. > > Maybe you can use "-Weffc++" -- this warns e.g. for un-initialized > attributes -- however, > - it generates MANY warnings, also from code in the standard library > - it will warn also when you assign a value in the constructor, but not > using initialization. The code: > class A{ > A():x(0){} > A(const A&a){x=a.x;} > int x; > }; > generates a warning for line 3: "warning: ‘A::x’ should be > initialized in the member initialization list" > > And of course, that's only a compile time check. > > I don't know any additional flags for gcc -- however: Do you know > "valgrind"? That's an independent program, which can be used to perform > checks for using of uninitialized memory on already compiled code -- it > will report the corresponding line in the source-code too. > > Axel >