Diagnostic 269: invalid format string conversion


Casue: 

This warning is triggered by a printf or scanf format specifier that is not appropriate for the type of the variable being printed.


Example: 

#include <stdio.h>

int main() {
   long int li = 0;
   printf("%ln",li);     // %l is the size specifier; the type specifer is missing
   printf("%ldn",li);  // OK
   return 0;
}

 

> icl -c /W4 diag269.cpp
Intel® C++ Compiler Professional for applications running on IA-32, Version 11.1    Build 20090511 Package ID: w_cproc_p_11.1.035
Copyright (C) 1985-2009 Intel Corporation.  All rights reserved.

diag269.cpp
diag269.cpp(5): warning #269: invalid format string conversion
printf("%l\n",li);
           ^ 



Resolution :

Use proper type specifier.


For more complete information about compiler optimizations, see our Optimization Notice.

Comments

's picture

#include <stdio.h>
main()
{
size_t a;
printf("Enter the value of a:");
scanf("%Iu",&a);
printf("%#Ix",a);
}

Gives me this warning messages...

size.c(6): warning #269: invalid format string conversion
scanf("%Iu",&a);
^

size.c(7): warning #269: invalid format string conversion
printf("%#Ix",a);
^

output is fine but i want to get rid of this warning message...Is there a way?
I used the above format specifiers based on this url--
http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx

Jennifer J. (Intel)'s picture

which version of the Intel C++ compiler are you using and which VC? I do not get this warning with 10.1 or 11.x.

Jennifer J. (Intel)'s picture

btw. please post such questions to our C++ forum - http://software.intel.com/en-us/forums/intel-c-compiler

's picture

Intel(R) C++ Compiler for Intel(R) EM64T-based applications, Version 8.1 Build 20051118 Package ID: W_CCE_PC_8.1.025

Jennifer J. (Intel)'s picture

8.1 version is very old. please upgrade to 11.0. This issue is fixed in the 10.1 and newer release. Or you can try the Parallel Composer.