From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26382 invoked by alias); 28 Apr 2006 14:39:11 -0000 Received: (qmail 26372 invoked by uid 22791); 28 Apr 2006 14:39:11 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-03.spheriq.net (HELO fra-del-03.spheriq.net) (195.46.51.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 28 Apr 2006 14:39:09 +0000 Received: from fra-out-01.spheriq.net (fra-out-01.spheriq.net [195.46.51.129]) by fra-del-03.spheriq.net with ESMTP id k3SEd4YW016915 for ; Fri, 28 Apr 2006 14:39:04 GMT Received: from fra-cus-02.spheriq.net (fra-cus-02.spheriq.net [195.46.51.38]) by fra-out-01.spheriq.net with ESMTP id k3SEd2Dx005400 for ; Fri, 28 Apr 2006 14:39:02 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-02.spheriq.net with ESMTP id k3SEcxdr022268 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Fri, 28 Apr 2006 14:39:01 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 03F36DA46 for ; Fri, 28 Apr 2006 14:38:58 +0000 (GMT) Received: from mail2.gnb.st.com (mail2.gnb.st.com [164.129.119.59]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A9DFE475AB for ; Fri, 28 Apr 2006 14:38:58 +0000 (GMT) Received: from [164.129.122.218] (gnx2364.gnb.st.com [164.129.122.218]) by mail2.gnb.st.com (MOS 3.5.8-GR) with ESMTP id CHG43125 (AUTH lyon); Fri, 28 Apr 2006 16:38:57 +0200 (CEST) Message-ID: <44522900.4090103@st.com> Date: Fri, 28 Apr 2006 14:45:00 -0000 From: Christophe LYON User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: gdb@sourceware.org Subject: Unused variables in testsuite Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/msg00329.txt.bz2 Hi all, While fixing our compiler, I came across strange tests in the GDB testsuite: in some source files, some variables are defined but not used by the code, but are references in the .exp. Is there anywhere a requirement that the compiler should allocate unused variable under -O0 ? 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) Thanks, Christophe.