* Ruediger Meier <sweet_f_a@gmx.de> [2012-11-26 13:42]:
On Monday 26 November 2012, Dominique Leuenberger a.k.a DimStar wrote:
A warning by the compiler does not mean you don't have to care for it.. It means the programmer is responsible to know what is happening in this code and there is NO guarantee between gcc versions that this is not 'just changing'.
The only valid solution is to fix the code.
See for example this code piece (C++)
### #include <iostream>
int foo() { int a = 5; int b = a + 1; }
int main() { std::cout << foo() << std::endl; } ###
What is the recommended output of this? this example is somewhat simple enough to understand what is going on... BUT the bad thing is, if you ever extend the function foo() with anything AFTER, you migh get a new return value, which is not what you wanted... hence the warning.
Best regards, Dominique (who wishes upstreams would learn about -Werror -Wall)
The example below also gives you "control reaches end of non-void function" and obviously the compiler (gcc 4.5.1) is wrong. A valid solution here is to ignore the warning or to fix gcc.
int main() { int i = 1; if (i == 1) { return 1; } }
(This is a stupid trivial example. You can imagine that there are also real world examples where the programmer knows for sure that the warning is invalid.)
Best regards, Dominique (who wishes upstreams would learn about -Werror -Wall)
Yes, if you want to break your build on any compiler update.
I find it generally useful to rebuild packages with clang or even scan-build when investigating compiler warnings. While it isn't completely without false positives, it is vastly better than gcc and its warnings are actually readable and give you some context often allowing you to issues or non-issues without even digging into the source files. -- Guido Berhoerster -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org