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?


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 resulting binary does not segfault but prints garbage (probably uninitialized data).

g++ still works fine and does not give any warning, even when compiling with -Wall.
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.)

Sebastian


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