Liste des Groupes | Revenir à c arch |
On Tue, 3 Sep 2024 23:19:36 +0000, David Brown wrote:Untyped vararg functions are a big risk factor for programming and are always difficult for static (or run-time) checking. The best you can do is limit them to the standard ones (the printf family is very useful), make sure you are always using declarations from common headers rather than "home-made" declarations, and use the tools you can (such as gcc and clang's format attribute checks).
On 03/09/2024 19:19, Bernd Linsel wrote:Something that might be an error in a 32-bit machine may not beOn 03.09.24 10:10, David Brown wrote:>
>
snip 8< - - - - - - - -
>(There are a few situations where UB in C could be diagnosed at>
compile-time, which are probably historical decisions to avoid
imposing too much work on early compilers. Where possible, UB that
can be caught at compile time, could usefully be turned into constrain
violations that must be diagnosed.)
And exactly these are the situations that I'd like to be warned from,
rather than the compiler making up something without telling.
>
Some of those /are/ warned about by compilers (but I'd rather the
standards said that they were errors). But in general, many can be
handled by good development practice and compiler warnings. Still,
compilers could always get better!
an error in a 36-bit {48, 64, 72} machine.
One thing that could make a big difference, I think, is to drop theHow does one call fprintf() under those rules ??
compilation model of each translation unit being compiled to a binary
object independently, with only a minimal amount of information for
linking. Link-time optimisation allows for many extra checks, not all
of which are currently implemented AFAIK. For example, it should be
possible to check that external declarations and definitions match up
correctly across modules - that's currently UB and rarely checked.
Les messages affichés proviennent d'usenet.