From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 968 invoked by alias); 19 Mar 2014 15:12:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 951 invoked by uid 89); 19 Mar 2014 15:12:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 19 Mar 2014 15:12:34 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BFB0C116465; Wed, 19 Mar 2014 11:12:32 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id hOjEy01hIx8W; Wed, 19 Mar 2014 11:12:32 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id C2DD811645C; Wed, 19 Mar 2014 11:12:31 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 7A866E05BC; Wed, 19 Mar 2014 08:12:30 -0700 (PDT) Date: Wed, 19 Mar 2014 15:12:00 -0000 From: Joel Brobecker To: "Agovic, Sanimir" Cc: "tromey@redhat.com" , "Boell, Keven" , "gdb-patches@sourceware.org" Subject: Re: [PATCH v5 10/15] vla: evaluate operand of sizeof if its type is a vla Message-ID: <20140319151230.GG4282@adacore.com> References: <1391704056-25246-1-git-send-email-sanimir.agovic@intel.com> <1391704056-25246-11-git-send-email-sanimir.agovic@intel.com> <20140228173704.GC16479@adacore.com> <0377C58828D86C4588AEEC42FC3B85A7177464DE@IRSMSX105.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0377C58828D86C4588AEEC42FC3B85A7177464DE@IRSMSX105.ger.corp.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-03/txt/msg00448.txt.bz2 > If the operand passed to sizeof evaluates to a variable length array > type then C99 requires that the size of the operand is evaluated at > runtime (otherwise at compile time). > > 1| int vla[n][m]; > > sizeof(vla[0]) // Operand type is a variable length type, size is evaluated at runtime > sizeof(vla[0][0]) // Operand type is an int, size is evaluated at compile time > > If the expression contains a side effects it is evaluated too > > sizeof(vla[i++]) // i gets modified as the operand is evaluated at runtime > sizeof(vla[i++][0]) // no modifications, operand type evaluates to int Very interesting! I guess whoever is writing ... sizeof(vla[i++][0]) ... instead of ... sizeof(vla[i + 1][0]) ... is trying to shoot himself in the foot! Thanks for the explanation. I confess that the C RM is often somewhat obscure to me. > I addressed all of your issues below. Thanks! I look forward to v6 :). Hopefully that'll be the final iteration. FYI: I have one patch already that's dependent on your patch series, and it has to do with handling of "ptype dynamic_sized_array" in Ada. Thanks! -- Joel