From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28417 invoked by alias); 28 Apr 2006 14:42:05 -0000 Received: (qmail 28407 invoked by uid 22791); 28 Apr 2006 14:42:05 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Fri, 28 Apr 2006 14:42:03 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FZUAQ-0007bs-Iq; Fri, 28 Apr 2006 10:41:58 -0400 Date: Fri, 28 Apr 2006 15:11:00 -0000 From: Daniel Jacobowitz To: Christophe LYON Cc: gdb@sourceware.org Subject: Re: Unused variables in testsuite Message-ID: <20060428144158.GA29211@nevyn.them.org> Mail-Followup-To: Christophe LYON , gdb@sourceware.org References: <44522900.4090103@st.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44522900.4090103@st.com> User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00330.txt.bz2 On Fri, Apr 28, 2006 at 04:38:56PM +0200, Christophe LYON wrote: > Is there anywhere a requirement that the compiler should allocate unused > variable under -O0 ? This sort of requirement is never documented anywhere; it's just a question of common practice. Which in practice means GCC, until someone is interested in making it more portable. > For instance, consider the test in gdb.cp/m-static.cc , m-static.h, > m-static1.cc. > You can see that in main() one defines "test4" which is not used, thus > need not be allocated. Then, using "print test4.elsewhere" under GDB > fails. [note that in this case the default (empty) constructor for test4 > has no side effects, thus test4 can be eliminated safely] > > In the same way, in gdb.mi/var-cmd.c , mi-var-display.exp, you can see > that function do_special_tests() defines several variables (eg 'u') and > does not use them, while the .exp file tries to "-var-create u * u". > > I modified these tests so that the variables are used, and they now pass > with our compiler. > > May I submit this small patch, or is there a requirement on GCC to > allocate even unused variables in -O0? (our compiler is not GCC) I'd recommend submitting it. We (CodeSourcery) have been slowly submitting patches to allow the testsuite to run with yet another compiler (ARM's); we hadn't gotten to this one yet, but I think it's in there somewhere, because I remember having to modify m-static*. -- Daniel Jacobowitz CodeSourcery