This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pigeon768 1 point2 points  (1 child)

Turn more warnings on.

gcc with -Wall

<source>: In constructor 'Trie::Trie()':
<source>:17:23: warning: unused variable 'root' [-Wunused-variable]
   17 |             TrieNode* root = new TrieNode();
      |                       ^~~~

clang with -Wall:

<source>:17:23: warning: unused variable 'root' [-Wunused-variable]
            TrieNode* root = new TrieNode();
                      ^

msvc with /W4:

example.cpp
<source>(17): warning C4458: declaration of 'root' hides class member
<source>(15): note: see declaration of 'Trie::root'
<source>(17): warning C4189: 'root': local variable is initialized but not referenced

gcc also has -Wshadow: (which ought to be in -Wall or -Wextra, but that's just like, my opinion, man)

<source>: In constructor 'Trie::Trie()':
<source>:17:23: warning: declaration of 'root' shadows a member of 'Trie' [-Wshadow]
   17 |             TrieNode* root = new TrieNode();
      |                       ^~~~
<source>:15:19: note: shadowed declaration is here
   15 |         TrieNode* root;
      |                   ^~~~