public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: quequero@linux.bitchx.it
To: gcc-gnats@gcc.gnu.org
Cc: quequero@linux.bitchx.it
Subject: optimization/7108: gcc 3.1 initialize two times the same variable
Date: Mon, 24 Jun 2002 13:46:00 -0000	[thread overview]
Message-ID: <20020624204416.3840.qmail@sources.redhat.com> (raw)


>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:


             reply	other threads:[~2002-06-24 20:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-24 13:46 quequero [this message]
2002-07-03 17:33 rth
2002-07-04  5:26 -=Quequero=-

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020624204416.3840.qmail@sources.redhat.com \
    --to=quequero@linux.bitchx.it \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).