Why does this code trigger gcc's “maybe uninitialized” warning?
Why does this code trigger gcc's “maybe uninitialized” warning? In plenty of other instances, gcc seems to be able to detect that the condition at the beginning of the loop initializes the variable. It even works if I drop the increment operator. It also goes away without the -02 flag. I've learned to trust that compiler warnings usually do mean something is wrong, so I'm wondering if there's something I'm missing or if it's just a weird compiler quirk. -02 void act(char **); void test(int width, int height){ char * rowA[width]; char ** A; for (int i = 0; i < width * height; ++i){ if (!(i % width)){ if (i){ act(rowA); } rowA[0] = 0; A = rowA; } *A++ = "hello"; } } Compiling on gcc-6.3.0 with -Wall -Werror -02 gcc-6.3.0 -Wall -Werror -02 Edit: to avoid confusion I've altered the code to be closer to the actual use case. ...
