-Wformat cannot use const struct fields as format strings on purpose?

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

 



Hi.

Here's a small piece of code:

	static struct {
		const char fmt[10];
	} const x = { "%d\n" };
	static const char * const fmt = "%d\n";
	printf(fmt, 1);
	printf(x.fmt, 1);

The second `printf` produces a warning:

    test.c:105:10: warning: format string is not a string literal
[-Wformat-nonliteral]
                    printf(x.fmt, 1);
                           ^~~~~

>From my point of view both format strings are identical. Why can't gcc
deduce the format string in the second case?



[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