I use g++ 4.4.3 and have the following alias so that I never forget to turn on the warnings:
$ alias g++
alias g++='g++ -ansi -pedantic -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings'
If compiled with the above, there would be some warnings. Following steps show how different options show different warnings.
Compilation with no warning option does not show any warning
$ \g++ sizeofarray.cpp
Turning on -Wall
$ \g++ -Wall sizeofarray.cpp
sizeofarray.cpp: In function ‘int main()’:
sizeofarray.cpp:12: warning: unused variable ‘q’
Turning on -Wextra
$ \g++ -Wall -Wextra sizeofarray.cpp
sizeofarray.cpp: In function ‘int main()’:
sizeofarray.cpp:12: warning: unused variable ‘q’
sizeofarray.cpp: At global scope:
sizeofarray.cpp: In instantiation of ‘int size(T (&)[N]) [with T = char, int N = 27]’:
sizeofarray.cpp:12: instantiated from here
sizeofarray.cpp:4: warning: unused parameter ‘Array’
Finally turning on -pedantic
to catch the real problem
$ \g++ -Wall -Wextra -pedantic sizeofarray.cpp
sizeofarray.cpp: In function ‘int main()’:
sizeofarray.cpp:12: warning: ISO C++ forbids variable length array ‘q’
sizeofarray.cpp:12: warning: unused variable ‘q’
sizeofarray.cpp: At global scope:
sizeofarray.cpp: In instantiation of ‘int size(T (&)[N]) [with T = char, int N = 27]’:
sizeofarray.cpp:12: instantiated from here
sizeofarray.cpp:4: warning: unused parameter ‘Array’