On 27/10/2024 05:37, Tim Rentsch wrote:
> Vir Campestris writes:
>
>> On 22/10/2024 13:48, Thiago Adams wrote:
>>
>>> I think a more generic feature would be to have a standard way of
>>> promoting selected warnings to errors. This would avoid stacking
>>> features with small differences, such as treating constexpr as a
>>> special case compared to other constant expressions in C.
>>
>> I have in the past had coding standards that require you to fix all
>> warnings. After all, sometimes they do matter.
>
> Everyone agrees that all warnings should be fixed. Where people
> differ is what set of warning conditions should be enabled.
>
> At (or at least near) one end of the spectrum is -pedantic.
Note that for most code, strict conformance to C standards is not a
major concern - most programs are at least somewhat platform specific or
compiler-specific. If that is the case, then it is a good thing to use
non-standard features if they make the code clearer or open the
possibility of more static checking.
>
> At the other end of the spectrum is -Weverything in clang. (I
> confess I am sort of assuming that -Weverything includes every
> warning condition known to man, which might not be the case. But
> I trust people can understand what is meant by "-Weverything".)
>
As I understand it, "-Weverything" was more intended for tests of the
compiler than an option anyone should use in practice. More realistic,
I think, would be "-Wall -Wextra" which enables several warnings that
many people would feel give a lot of hits on perfectly good code.
> I expect most people would advocate a point somewhere between the
> two extremes. But there are different ideas about where that
> point should be.
>
Yes - and there /should/ be different ideas there.
> Whether warnings can or should be turned into errors is a
> separate question. The first question is what set of warning
> conditions should be enabled. A statement that all warnings
> should be fixed is meaningless if there is no indication of
> what warning conditions should be enabled.
Agreed - deciding on the warnings to use is critical.
In my mind, the important aspect of turning warnings into errors is that
the won't be overlooked or forgotten. It's easy to miss warnings in the
middle of larger builds - errors are usually much harder to ignore
(intentionally or unintentionally).
|
|