On 5/11/20 12:43 AM, Kamil Dudka wrote: > It is usually bad idea to use different versions of source code for compilers > and for static analyzers.
Yes, I don't like it either. The patch I installed was particularly bad, since the workaround code was buggy. My only excuse is that the GCC bug itself is quite bad. Sometimes if your tools are bad it infects your own work.... > There might be some exceptions where skipped initialization or cleanup brings > measurable speedup. However in most of the cases the *_LINT macros are just > useless obfuscation of the source code. This 100% backwards. The IF_LINT constructions are not primarily for performance. They are primarily so that one can do better static checking if one has good tools. If you have a good tool, you can arrange for IF_LINT(X) to be empty. If you have a tool that is not so good (GCC comes to mind :-), then you may can arrange for IF_LINT(X) to expand to X to prevent the less-capable tool from crying wolf. > I use the following patch in Fedora coreutils to make static analyzers see > the code that is actually going to run This is also wrong. If you want static analyzers to see the code that is actually going to run, then you should build the software the same way for the static analyzers that you do for the running code. This is elementary, and you have to do that anyway for all the other configuration flags you may use. IF_LINT is not special here. We shouldn't get rid of the IF_LINT expressions, ugly as they are, because they tell us what the code would look like if we had better static analysis tools, and this is useful information to the human reader even when our tools are inadequate.