From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4915 invoked by alias); 24 Jun 2002 20:46:08 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 4873 invoked by uid 71); 24 Jun 2002 20:46:02 -0000 Resent-Date: 24 Jun 2002 20:46:02 -0000 Resent-Message-ID: <20020624204602.4871.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, quequero@linux.bitchx.it Resent-Reply-To: gcc-gnats@gcc.gnu.org, quequero@linux.bitchx.it Received: (qmail 3841 invoked by uid 61); 24 Jun 2002 20:44:16 -0000 Message-Id: <20020624204416.3840.qmail@sources.redhat.com> Date: Mon, 24 Jun 2002 13:46:00 -0000 From: quequero@linux.bitchx.it Reply-To: quequero@linux.bitchx.it To: gcc-gnats@gcc.gnu.org Cc: quequero@linux.bitchx.it X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: quequero@linux.bitchx.it Subject: optimization/7108: gcc 3.1 initialize two times the same variable X-SW-Source: 2002-06/txt/msg00569.txt.bz2 List-Id: >Number: 7108 >Category: optimization >Synopsis: gcc 3.1 initialize two times the same variable >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: pessimizes-code >Submitter-Id: net >Arrival-Date: Mon Jun 24 13:46:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: gcc 3.1 Thread model: single >Release: 3.1 >Organization: >Environment: Linux 2.4.18 #16 Tue May 28 14:07:34 CEST 2002 i686 >Description: Look here: void function(char *string){ char buffer[100]; int i=0; .... Now, let's disassemble it (i have used stripped and non-stripped version of the executable): .text:08048492 push ebp .text:08048493 mov ebp, esp .text:08048495 sub esp, 98h .text:0804849B mov [ebp+i], 0 .text:080484A2 mov [ebp+i], 0 the same variable is initiaziled twice :) >How-To-Repeat: i've discovered it compiling a silly program that i'm writing for a demonstration: void overflow(char *string); int main(int argv, char *argc[]){ overflow(argc[1]); } void overflow(char *string){ char buffer[100]; int i=0; for(i=0; i<=100; i++) buffer[i] = string[i]; printf("Typed: %s\n", buffer); } the disassembling the funciot "overflow" with IDA: .text:0804849B mov [ebp+i], 0 .text:080484A2 mov [ebp+i], 0 i can see that "int i" is initialized twice to 0 but as you can see ebp doesn't change so that instruction shouldn't be there :P >Fix: i really don't know >Release-Note: >Audit-Trail: >Unformatted: