Another issue with diagnostic format-checker
Gabriel Dos Reis
gdr@integrable-solutions.net
Sun Jul 20 14:34:00 GMT 2003
"Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:
| > The diagnostic framework does already some check at run-time. If a front
| > end does not register a format specifier, it halts compilation if the
| > execution path uses it. So we do have some consistency check.
| >
| > What the format specifiers checker buys us is the ability to tell
| > whether a given pair of format specifier and argument are used
| > consistently. It does NOT check whether a format specifier is
| > *effectively* handled -- that check is done at run-time.
| >
| > Both are complimentary, and NOT mutually exclusive.
|
| Well, the consistency check at gcc runtime calls abort if it
| encounters a non-valid specifier. That is a "bad user experience"
| IMHO. Better to catch these and fix them at gcc compile-time with the
| static format checker. If the format checker is doing its job, the
| runtime check is redundant.
No, it is not redondant. The format checker does not know whether
there is a code to effectively handle a given format specifier. The
only thing it knows is that some set of format specifiers is
*intended* (or acceptable) for use.
It is like having an abstract base class
struct formatter {
virtual handle_D(...) = 0;
virtual hanlde_E(...) = 0;
void operator()(...);
};
used as follows:
struct c_diagnostic_reporter : formatter {
// ...
};
if you don't declare a handler (listed in formatter) in c_formatter,
then the format checker will catch you because, then you cannot have
c_diagnostic_reporter warning;
warning(...);
The format specifier won't say anything, but that does not guarantee
that you do have an actual implementation for any handled declared in
c_diagnostic_reporter. In really, you'll get a link error (at best)
or obscure "call to pure virtual function" failure at run-time.
That is part of the check is what run-time check in the current
diagnostic framework does. As you can see, it is not redundant.
-- Gaby
More information about the Gcc
mailing list