Community
Participate
Working Groups
Build Identifier: CDT 8.1 I get false positive warnings about members not initialized in constructor when constructor calls non-const method. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=339795#c51 Current implementation of checker only works when constructor definition is in header file but fails if definition is in .cpp source file. Reproducible: Always
Hi Axel, I tried this and couldn't reproduce the false positive: ---test.h--- #ifndef TEST_H_ #define TEST_H_ class C { public: int field; C(); }; #endif ---test.cpp--- #include "test.h" void initObject(C* c); C::C() { initObject(this); } Does that work for you?
(In reply to comment #1) > Hi Axel, I tried this and couldn't reproduce the false positive: That was using master b939129f (8.1) which is about a week old.
Ah I see now a fp now if I put initObject inside the class to make it a method. Was that the fp you encountered?
> Ah I see now a fp now if I put initObject inside the class to make it a method. > Was that the fp you encountered? I was using the code you mentioned in comment #1. I used a nightly build from January to test it. You might have found another fp.
*** cdt git genie on behalf of Marc-Andre Laperle *** Bug 368419 - FP in members not initialized in constructor [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=0a9a95adcd3ba273c1b67a11483d19d435f2b2f2
(In reply to comment #4) > > Ah I see now a fp now if I put initObject inside the class to make it a method. > > Was that the fp you encountered? > I was using the code you mentioned in comment #1. I used a nightly build from > January to test it. You might have found another fp. I fixed the fp when the non-const method is used but I still can't reproduce the fp when a function is used. Sorry to ask but can you try again with a recent nightly build? I must be missing something... or maybe you really did have initObject as a method.
(In reply to comment #6) > I fixed the fp when the non-const method is used but I still can't reproduce > the fp when a function is used. Sorry to ask but can you try again with a > recent nightly build? I must be missing something... or maybe you really did > have initObject as a method. I think you are right. I had initObject() as a method. That is the usual way I implement a class. So I can reset the object anytime I want by calling initObject(). You can close the bug then.
OK, thanks Axel!