From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58387 invoked by alias); 23 Aug 2018 14:07:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 58375 invoked by uid 89); 23 Aug 2018 14:07:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Aug 2018 14:07:56 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1C832AE53; Thu, 23 Aug 2018 14:07:54 +0000 (UTC) Date: Thu, 23 Aug 2018 14:07:00 -0000 From: Michael Matz To: Richard Biener cc: Martin Sebor , GCC Patches Subject: Re: [PATCH] print full STRING_CST in Gimple dumps (PR 87052) In-Reply-To: Message-ID: References: <5ee56fe9-bf96-196f-6bd6-6ecbda2d1ca0@gmail.com> <95ad560d-2f0d-b102-d852-3284c8da685a@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg01477.txt.bz2 Hi, On Thu, 23 Aug 2018, Richard Biener wrote: > > > Can you write a not \0 terminated string literal in C? > > > > Yes: char a[2] = "12"; > > I thought they are fully defined in translation phase #1 ... No, you can't write a string literal which is not zero terminated, because in translation phase 7 a zero code is appended to all character sequences resulting from string literals, which is then used to allocate and initialize a static (wide) character array of just the right size, including the zero code. The above construct uses that static char[3] array from the string literal to initialize a char[2] array (which is explicitely allowed), and _that_ one is not zero terminated. But it's also no string literal. (Of course, due to as-if the intermediate char[3] array won't usually be explicitely constructed.) Ciao, Michael.