From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26285 invoked by alias); 24 May 2009 09:04:20 -0000 Received: (qmail 26269 invoked by uid 22791); 24 May 2009 09:04:17 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.155) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 24 May 2009 09:04:12 +0000 Received: by fg-out-1718.google.com with SMTP id 13so889212fge.5 for ; Sun, 24 May 2009 02:04:09 -0700 (PDT) Received: by 10.86.91.3 with SMTP id o3mr4606030fgb.40.1243155848960; Sun, 24 May 2009 02:04:08 -0700 (PDT) Received: from 93-103-18-160.static.t-2.net (93-103-18-160.static.t-2.net [93.103.18.160]) by mx.google.com with ESMTPS id d6sm8240567fga.22.2009.05.24.02.04.08 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 24 May 2009 02:04:08 -0700 (PDT) Message-ID: <4A190D87.6070008@gmail.com> Date: Sun, 24 May 2009 09:47:00 -0000 From: Uros Bizjak User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: GCC CC: Dave Korn , "H.J. Lu" Subject: Re: What does zero-length array mean at file scope? Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg00588.txt.bz2 Hello! > I found something rather odd in testcase gcc.c-torture/execute/20030811-1.c: > > > /* Origin: PR target/11535 from H. J. Lu */ > > > > void vararg (int i, ...) > > { > > (void) i; > > } > > > > int i0[0], i1; > > Huh? > > > void test1 (void) > > { > > int a = (int) (long long) __builtin_return_address (0); > > vararg (0, a); > > } > > > > void test2 (void) > > { > > i0[0] = (int) (long long) __builtin_return_address (0); > > } > > Nasal demons? > > > void test3 (void) > > { > > i1 = (int) (long long) __builtin_return_address (0); > > } > > > > void test4 (void) > > { > > volatile long long a = (long long) __builtin_return_address (0); > > i0[0] = (int) a; > > } > > > And testing it on Linux, I see that the linker goes ahead and assigns zero > bytes of the common area to i0, then assigns four bytes of common space to i1 > at the same address, so writing to i0[0] aliases and alters i1. That > certainly sounds like undefined behaviour to me! > It looks like a typo in the testcase to me, but let's add some CCs to be sure. Uros.