[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Conformant C code, and compiler warnings...
- From: Mouse <mouse@...>
- Date: Wed, 8 Mar 2023 22:00:32 -0500 (EST)
>> As far as warnings go ... it always amazes me when I build an
>> established Project from source and the compiler issues warnings.
> Over time, compiler toolchains have steadily improved [...] their
> ability to issue warnings [...]
Yes, but some of those warnings are special-purpose or, depending on
your mindset, outright crazy. For an example of the former, consider
gcc's -Waggregate-return, which as far as I can tell is of no value
except when porting to compilers with broken or missing aggregate
return support, or when forced to use ABIs with ridiculously expensive
aggregate return support. For an example of the latter, consider
-Wunused-result, which I have to turn off whenever I build my code on
Linux because someone got a bee in their bonnet about some function's
return values (I don't recall which one) and decided that ignoring the
return value indicated my code was broken somehow (if I could recall
which function, I could explain why I believe otherwise). So I use
-Wno-unused-result.
Of course, there are also lots of useful warnings. But I do not think
it is useful to treat all warnings as somehow equivalent, as in
speaking of "...and the compiler issues warnings".
> Once code becomes well-established, it becomes more difficult to
> consider changing it for any reason, including toolchain warnings.
If that's a sane stance, then the warning should be turned off. If the
warning is worth listening to, then the code has a bug, even if it's a
latent one on current systems, and should be fixed.
Also, sometimes, the project's code is wrong. I once ran into an
example, a project with code which depended on a "creative" (and, based
on an email exchange with someone who was on X3J11, wrong)
interpretation of the standard - but whose incorrect code happened to
work on most modern machines. I doubt it's the only such.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B