This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Threaded Binary Tree Worked with same code a few days ago under g++ in ubuntu 16.04
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: nick <xerofoify at gmail dot com>
- Cc: GCC help <gcc-help at gcc dot gnu dot org>
- Date: Sun, 27 Nov 2016 22:48:59 +0100
- Subject: Re: Threaded Binary Tree Worked with same code a few days ago under g++ in ubuntu 16.04
- Authentication-results: sourceware.org; auth=none
- References: <1b18bb13-e0d0-2cae-98f2-546d4d22ed4a@gmail.com>
* nick:
> Greetings all, Sorry for the stupid question but I for whatever
> reason can't get this to work and was wondering if it's me being
> stupid or something else.
The first step is to fix all compiler warnings:
threadedtree.h: In instantiation of ‘ThreadedTree<T>::iterator ThreadedTree<T>::insert(const T&) [with T = int]’:
main.cc:6:16: required from here
threadedtree.h:282:17: warning: operation on ‘tmp->ThreadedTree<int>::Node::rightThread’ may be undefined [-Wsequence-point]
tmp->rightThread = tmp->rightThread = true;
^
Then run under valgrind:
==7877== Conditional jump or move depends on uninitialised value(s)
==7877== at 0x400D30: ThreadedTree<int>::printTree() (threadedtree.h:244)
==7877== by 0x400A2B: main (main.cc:8)
==7877== Uninitialised value was created by a heap allocation
==7877== at 0x4C29180: operator new(unsigned long) (vg_replace_malloc.c:324)
==7877== by 0x400BFA: ThreadedTree<int>::insert(int const&) (threadedtree.h:280)
==7877== by 0x400A1F: main (main.cc:7)
I have no idea if this points towards the cause of the bug, but it's
always worth a try.