From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14525 invoked by alias); 18 Jul 2009 12:18:37 -0000 Received: (qmail 14512 invoked by uid 22791); 18 Jul 2009 12:18:37 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from wf-out-1314.google.com (HELO wf-out-1314.google.com) (209.85.200.170) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 18 Jul 2009 12:18:31 +0000 Received: by wf-out-1314.google.com with SMTP id 25so414408wfc.14 for ; Sat, 18 Jul 2009 05:18:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.143.161.3 with SMTP id n3mr482726wfo.338.1247919509528; Sat, 18 Jul 2009 05:18:29 -0700 (PDT) In-Reply-To: <4A61A230.9000703@redhat.com> References: <6215dcff0907180232l1c7291eclbc006cabd02224a4@mail.gmail.com> <6215dcff0907180235g7b4e6b7bl18f151db959a989d@mail.gmail.com> <4A61A230.9000703@redhat.com> Date: Sat, 18 Jul 2009 12:18:00 -0000 Message-ID: <6215dcff0907180518k3ddf4908ub29b36acc24f91f@mail.gmail.com> Subject: Re: array semantic query From: dharmendra pandit To: Andrew Haley Cc: gcc@gcc.gnu.org, gcc-help@gcc.gnu.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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-07/txt/msg00340.txt.bz2 According to 6.3.2.1 Para 3, the type conversion from "array of type" to "pointer to type" should happen irrespective of whether the operand is on right had side or the left hand side of assignment operator. But GCC is converting only the right side operator type to "pointer of type" while retaining the left hand side type to be "array of type". -Dharmendra On Sat, Jul 18, 2009 at 3:51 PM, Andrew Haley wrote: > On 07/18/2009 10:35 AM, dharmendra pandit wrote: >> Hi, >> >> I tried the following simple code segment in gcc and it gave the >> incompatible type error as mentioned below. >> >> int main() { >> =A0 =A0 int arr[10]; >> =A0 =A0 arr =3D arr; =A0 // error: incompatible types when assigning to = type >> =91int[10]=92 from type =91int *=92 >> } >> >> Here it seems GCC is retaining the left hand side type of arr to be >> array of 10 ints whereas on the right hand side >> it has changed its type from array to pointer to integer. I tried >> searching the relevant sections in the standard ISO C >> document number WG14/N1124 justifying the above behaviour of GCC but >> failed to conclude it from the specifications. >> It would be of great help if someone can point me out the relevant >> sections from the specs. > > 6.3.2.1 Para 3. > > I'm surprised you ask, since this convention has been used since early > K&R C. > > Andrew. > >