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: const char wd[6] = "Wednes", is that legal?


Hi Joakim,
On Tue, Nov 30, 2010 at 03:40:12PM +0100, Joakim Tjernlund wrote:
> gcc 4.4.5, powerpc32 does not fail
>  const char wd[6] = "Wednes";
> even though wd only has room for 6 chars. Is this intended?
Which language are you using? ;-)
In C++, it's forbidden (there has to be enough space for the implied
trailing "\0".
In C whoever, it's legal -- you obtain an array of 6 characters, without
a trailing "\0" ...

Axel


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