uninitialized member warnings ?
Lubos Lunak
l.lunak at suse.cz
Wed Sep 26 06:29:16 PDT 2012
On Wednesday 26 of September 2012, Michael Meeks wrote:
> On Tue, 2012-09-25 at 14:26 +0200, Stephan Bergmann wrote:
> > > Neato :-) the deeper question - as to why no warnings are popping out
> > > of the compiler for this when (surely) it's a trivial thing to check /
> > > warn for - is more concerning.
> >
> > Such a warning option has never been there AFAIK.
>
> Oh - must be me mis-remembering it, or remembering valgrind output that
> catches that, silly me.
>
> > There is no way for the compiler to decide this in general (unlike Java,
> > C++ does not have restricting rules to allow the compiler to do so).
>
> no way ? surely there is - add a warning for un-initialized POD members
> on the exit of the constructor. It seems that fools seldom differ, and
> there is such a patch here:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=2972
>
> Doesn't seem to be going anywhere in the last month, but - you can but
> hope :-)
I don't think it can go anywhere practical:
class A
{
bool foo;
void init();
public:
A() { init(); }
};
How should the compiler know?
--
Lubos Lunak
l.lunak at suse.cz
More information about the LibreOffice
mailing list