Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

over 6 years ago

Language

C

Compiler

gcc 8.2.0

Options
Warnings
C11
-pedantic-errors
Raw compiler options
-Wshadow

Author

anonymous

over 6 years ago

$ gcc prog.c -Wall -Wextra -std=c11 -pedantic-errors -Wshadow
prog.c: In function 'print2':
prog.c:35:21: warning: declaration of 'subTotal' shadows a previous local [-Wshadow]
     for (int i = 0, subTotal = 0; i < n; i++) {
                     ^~~~~~~~
prog.c:34:12: note: shadowed declaration is here
     double subTotal;
            ^~~~~~~~
prog.c:38:23: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
             printf("%lf~~~", subTotal);
                     ~~^      ~~~~~~~~
                     %d
prog.c:34:12: warning: unused variable 'subTotal' [-Wunused-variable]
     double subTotal;
            ^~~~~~~~
prog.c: In function 'print4':
prog.c:61:25: warning: declaration of 'subTotal' shadows a previous local [-Wshadow]
         for (int j = 0, subTotal = 0; j < m; j++) {
                         ^~~~~~~~
prog.c:59:12: note: shadowed declaration is here
     double subTotal;
            ^~~~~~~~
prog.c:63:23: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
             printf("%lf~~~", subTotal);
                     ~~^      ~~~~~~~~
                     %d
prog.c:59:12: warning: unused variable 'subTotal' [-Wunused-variable]
     double subTotal;
            ^~~~~~~~
1.000000~~~4.000000~~~9.000000~~~
11.000000~~~15.000000~~~21.000000~~~
******************
21.000000~~~21.000000~~~21.000000~~~
21.000000~~~21.000000~~~21.000000~~~
******************
1.000000~~~4.000000~~~9.000000~~~
2.000000~~~6.000000~~~12.000000~~~
******************
12.000000~~~12.000000~~~12.000000~~~
12.000000~~~12.000000~~~12.000000~~~
******************
1.000000~~~3.000000~~~5.000000~~~
2.000000~~~4.000000~~~6.000000~~~
******************
Exit Code:
0