On Tuesday 2008-12-16 18:01, Sebastian Redl wrote: > Michel Van den Bergh wrote: >> That's strange. When I try to compile this with gcc 4.3.2 on Ubuntu 8.10 >> (Intel core2 duo) >> I get >> >> stest.c: In function ‘main’: >> stest.c:13: warning: format ‘%s’ expects type ‘char *’, but argument 2 has >> type ‘char[20]’ >> > The C++ standard says in 5.2.2p7: "The lvalue-to-rvalue, array-to-pointer, and > function-to-pointer standard conversions are performed on the argument > expression." > > The C standard says no such thing; only integer promotions are performed. (See > 6.5.2.2 of the C99 final draft.)
But what about char t[20]; printf("%s\n", t); typeof(t) is char[20], and if no promotion is performed, how come it is converted to char* in C?