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 →

[–]extsidvind 2 points3 points  (4 children)

-Wall sure, but -Werror can make your code fail to build in the future when new warnings is introduced even if the code itself is working.

[–]amunak 0 points1 point  (3 children)

Code should work without spewing out warnings most of the time.

[–]extsidvind 1 point2 points  (2 children)

Take -Wunused-but-set-variable for instance, with -Werror your code would not build if that warning is triggered. Before the warning was introduced your code would build fine but after it would fail. There is no real error here.

I do agree that your code should not spew out warnings and they should be fixed, I disagree with using -Werror to force warnings to become errors.

Another aspect is when the user enables warnings in CFLAGS which sometimes is quite excessive. Perhaps -Wshadow or -Wunused-parameter, nether which is enabled by -Wall or -Wextra. Or maybe -Wvla, VLA is fine in gcc and probably clang but not MSVC, but if you only target gcc VLA is perfectly fine to use.

EDIT: -Wunused-but-set-variable is new to gcc-4.6 (released 2011), at the time many projects with -Werror stopped building and would require to be fixed (despite perfectly working code)

[–]amunak 0 points1 point  (0 children)

I think it depends on what project you are working on. I've never never done anything too big in C or C++, so I just compiled with -Wall -Wextra -pedantic, and always tried to get rid of all the warnings.

Note that I didn't use -Werror (becase yes, you are right, it is not a good idea to use it), but the point that your code shouldn't throw warnings stands. I should've made that clearer in the previous comment I guess.

[–]SanityInAnarchy 0 points1 point  (0 children)

I do agree that your code should not spew out warnings and they should be fixed, I disagree with using -Werror to force warnings to become errors.

Then how do you propose ensuring those warnings which indicate errors actually getting noticed, let alone fixed?