Notes from C++ static analysis
Marco Leise
Marco.Leise at gmx.de
Wed Jun 26 13:51:29 PDT 2013
Am Wed, 26 Jun 2013 22:13:29 +0200
schrieb "Adam D. Ruppe" <destructionator at gmail.com>:
> On Wednesday, 26 June 2013 at 20:06:43 UTC, H. S. Teoh wrote:
> > But if the format string is known at compile-time, and there are
> > extraneous arguments, then it should be a warning / error.
>
> We can't do that in D today, unless we do a writefln!"fmt"(args)
> in addition to writefln(fmt, args...);
>
> tbh I kinda wish we could overload functions on literals though.
So the compiler would eagerly turn arguments into compile-time
parameters and offer some trait to check if a particular
instantiation of writefln made 'fmt' a template argument ?
static if (__traits(ctKnown, fmt)) {
// do static analysis of format specifiers
} else {
// regular code path
}
--
Marco
More information about the Digitalmars-d
mailing list