This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A bug?


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]