16 ms·
> Why are those warnings not automatically included in "-Wall -Wextra"? Is there any issue with enabling them? Are these somewhat experimental? Because tons of
by jcelerier 9y ago
> Why are those warnings not automatically included in "-Wall -Wextra"? Is there any issue with enabling them? Are these somewhat experimental?
Because tons of people keep complaining "muh my build breaks if they enable new warnings". Dammit, idiots, if your build break there's a good chance your software is already broken too; that's the point of breaking the build: making bugs visible so that you have to fix them.
- craftyguy 9y agothat's a terrible excuse for not enabling them in -Wall. Is there a -Wreally-all?
- loeg 9y agoClang has -Weverything. GCC doesn't: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66293 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66293
- jordigh 9y agoIt looks like -Weverything for gcc would make a lot of code not compile (along with -Werror). For example, it would include -Weffc++, right? Those are warnings if your code just doesn't obey one guy's now-outdated opinions of what C++ should look like. That's what this says at the bottom: https://github.com/Tuplanolla/gcc-weverything https://github.com/Tuplanolla/gcc-weverything
- jcelerier 9y ago> For example, it would include -Weffc++, right? Maybe, but where's the problem ? Just add -Wno-effc++ afterwards.
- loeg 9y agoYes, -Weverything + -Werror is often a silly combination. That isn't a GCC-specific problem, though. Clang with both flags will fail to compile quite a lot of code, too. As the other reply points out, you can just use -Wno-effc++ on top of -Weverything. You could also avoid that particular problem by not using C++ ;-).
- kllrnohj 9y agoNote that Clang recommends you don't use -Weverything because it contains warnings that are in development or have a known high false-positive rate.
- klodolph 9y agoThe actual reason why -Wall doesn't include more warnings is because too many people rely on the fact that -Wall includes warnings for questionable code that is easy to avoid. It's a bad name, but it's not being changed any time soon.
- loeg 9y agoQuite a few of the warnings not enabled in -Wall or -Wextra fail spuriously on good code. In combination with -Werror, new failures on perfectly fine code is frustrating for developers.
- krylon 9y agoI'd rather have a couple of false positives and then selectively disable warnings (I think one can use pragmas to disable specific warnings for specific regions of code in gcc). At least, I would like an additional flag that really does enable all warnings, say -Wabsolutelyall or something like that.
- marcosdumay 9y agoYou probably don't want that, but a flag that enables all sensible messages, yet does not enable stuff that is there just for compatibility or because it's useful in some context. It should also disable Werror, otherwise we will be claiming for some new flags in a few years.
- quotemstr 9y agoThat's why you don't enable -Werror in release builds, contrary to received wisdom on the subject. When you compile with -Werror, you surrender control over your build's success to the whims of the same people who think that it's okay that memcpy(0, 0, 0) is undefined behavior. The personal opinions of future compiler authors shouldn't affect whether your program builds successfully. Sometimes warnings are bogus. Sure, use -Werror in development. But don't make it the default.
- johannes1234321 9y agoThe opinions of (future) compiler authors decides already wether your programm will work in all cases. With those warnings they indicate some of their decisions.
- quotemstr 9y agoFuture compiler authors are at least in theory beholden to current language specifications. If a program does something legal that a compiler author feels is a bad idea, the compiler can whine all it wants, but it still has to compile the program. Compilers drop support for older specifications far less often than they add new warnings.
- AgentME 9y agoIn general yes, but the posts above were talking about a warning about undefined behavior, so the standard says that anything could happen in that case.
- tomsmeding 9y agoThis is especially true for warnings about && and || precedence. When you use those two operators in one expression without parentheses, IIRC both gcc and clang complain, but I once wanted to compile some software that thought it was a good idea to -Werror all the code and don't use parens around &&. Fun times fixing all the zillion makefiles that mentioned Werror. (Yay autoconf?)
- deleted 9y ago[deleted]
- balls187 9y agoIf you knowingly upgrade libraries and/or other project dependencies you wouldn't expect backward compatibility (assume semver conventions), do you? Why would upgrading a compiler be any different?
- bkanter 9y agoAs usual, HN lectures but has no clue: The missing warnings are mostly in the style "did you really mean to do this ...?" and can be very annoying. You have to use pragmas or rewrite perfectly working code to get rid of them. Now clutter the code with compiler specific pragmas for gcc, clang, visual studio if you enable all warnings on each and you'll see what I mean. But probably you haven't even used a C compiler yet.
- sytelus 9y agoEverybody should use this in their new projects: http://shitalshah.com/p/how-to-enable-and-use-gcc-strict-mode-compilation/ http://shitalshah.com/p/how-to-enable-and-use-gcc-strict-mod...