Re: No error message when format string is passed as variable to printf functions family

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 14, 2015 at 12:31:50AM +0200, john smith wrote:
> >> const char *str = "Last printf: %B\n";
> >> printf(str, 2);

> But why is indirection done when string is defined as an array and not
> when it is a pointer to constant string?

Because a literal is a literal, and a pointer is not.

See -Wformat-nonliteral, -Wformat=2, and the documentation for those.


Segher




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux