This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: 'SR.1419' is used uninitialized in this function...
On Tue, Jan 25, 2005 at 12:48:58PM -0800, Benjamin Redelings wrote:
> struct branchview;
>
> struct iterator
> {
> unsigned circuits; // Warning goes away if you remove this line
>
> virtual branchview operator*() const; // Warning goes away if you remove 'virtual'
>
> iterator() {}
> };
>
> struct branchview
> {
> iterator my_iterator() const {return iterator();}
>
> branchview(){}
> };
>
> inline branchview iterator::operator*() const {
> return branchview();
> }
>
> // You have to do this inside a template to get the bug, I think.
> template<class iterator_t>
> inline void append(const iterator_t& start, branchview& t) {
> iterator_t i = start;
> t = *i;
> }
>
> void iterator_set(const branchview& bv1,branchview& bv2) {
> append(bv1.my_iterator(),bv2);
> }
The result of my_iterator is unnamed, and the element circuits
is indeed uninitialized when it it copied to "i" in append.
Ergo I do not see the warning as actively incorrect, modulo the
name used in the warning text.
r~