error: 'root' may be used uninitialized in this function