Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761747AbXHBVJj (ORCPT ); Thu, 2 Aug 2007 17:09:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761823AbXHBVJF (ORCPT ); Thu, 2 Aug 2007 17:09:05 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:38881 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761663AbXHBVJD (ORCPT ); Thu, 2 Aug 2007 17:09:03 -0400 Date: Thu, 2 Aug 2007 22:09:02 +0100 From: Al Viro To: Guennadi Liakhovetski Cc: linux-kernel@vger.kernel.org Subject: Re: gcc fixed size char array initialization bug - known? Message-ID: <20070802210902.GQ21089@ftp.linux.org.uk> References: <20070802200856.GO21089@ftp.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 933 Lines: 29 On Thu, Aug 02, 2007 at 10:26:37PM +0200, Guennadi Liakhovetski wrote: > > Worse yet, K&R explicitely writes: > > > > char pattern[] = "ould"; > > is a shorthand for the longer but equivalent > > char pattern[] = { 'o', 'u', 'l', 'd', '\0' }; > > > > In the latter spelling gcc < 4.2 DOES warn too. Does warn for what? Array with known size? Sure, so it should - you have excess initializer list elements. Note the [] in the quoted - it does matter. Again, it's perfectly legitimate to use string literal to initialize any kind of array of character type. \0 goes there only if there's space for it; if array size is unknown, the space is left. That's it. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/