SAL at Microsoft

Walter Bright newshound2 at digitalmars.com
Mon Feb 28 10:16:51 PST 2011


bearophile wrote:
>> But I don't understand how a __format_string annotation helps here.
>>
>> If you have code like this:
>>
>> string f = "%d";
>> writeln(f, 10);
>>
>> Adding that annotation (here translated to a D annotation) doesn't help the compiler much:
>>
>> @format_string string f = "%d";
>> writeln(f, 10);
> 
> There's a bug there, the code needs to be:
> 
> @format_string string f = "%d";
> writefln(f, 10);
> 
> In most cases you don't want to print a format string, so if you write:
> 
> @format_string string f = "%d";
> writeln(f, 10);
> 
> The compiler is probably able to show a warning, that says that you are using a format string as first argument of a printing function that doesn't use a format string :-) And this warning is enough to catch that bug.


Won't implement, see rationale http://d.puremagic.com/issues/show_bug.cgi?id=4458#c6


More information about the Digitalmars-d mailing list