[Bug c++/19808] miss a warning about uninitialized member usage in member initializer list in constructor
anthony.brandon at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Nov 15 23:11:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19808
Anthony Brandon <anthony.brandon at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anthony.brandon at gmail dot com
--- Comment #24 from Anthony Brandon <anthony.brandon at gmail dot com> ---
Hi,
> It could be done specifically for uses in mem-initializers by walking the
> initializer in perform_mem_init to look for any references to members that
> haven't been marked yet.
I've been working on this using this approach.
At the moment I can detect and give a warning for something like:
struct S
{
int i, j;
S() : i(j), j(1) {}
};
However it doesn't cover cases like i(j+1), and in the case of i(i) there would
currently be two warnings (due to -Winit-self).
Lastly, the warning is given like so:
a.cpp:8:2: warning: ‘S::i’ is initialized with uninitialized field ‘S::j’
[-Wuninitialized]
S() : i(j), j(b) {}
^
So I have a couple of questions:
* How to get the right location for the mark. In other words:
S() : i(j), j(b) {}
^
* Is there a function to traverse a tree structure looking for a particular
tree (or some other way to get things like i(j+1) to work)?
* Should this give a warning in the case of i(i)?
More information about the Gcc-bugs
mailing list