From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27782 invoked by alias); 3 Feb 2003 23:42:38 -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 27753 invoked by uid 48); 3 Feb 2003 23:42:38 -0000 Date: Mon, 03 Feb 2003 23:42:00 -0000 Message-ID: <20030203234238.27752.qmail@sources.redhat.com> To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, jeronimo@mime.univ-paris8.fr, nobody@gcc.gnu.org From: bangerth@dealii.org Reply-To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, jeronimo@mime.univ-paris8.fr, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: c/9557: gcc 2.95.3 20010315 (SuSE) problem with place of variable X-SW-Source: 2003-02/txt/msg00159.txt.bz2 List-Id: Synopsis: gcc 2.95.3 20010315 (SuSE) problem with place of variable State-Changed-From-To: open->closed State-Changed-By: bangerth State-Changed-When: Mon Feb 3 23:42:38 2003 State-Changed-Why: User error -- read sscanf man page: ----------------------- struct lien *con; short port; con=(struct lien *)malloc(sizeof(struct lien)); sscanf(n_service, "%d", &port); con->adr4.sin_port =1; -------------------------- Using a short with %d is bound to write beyond its bounds. You overwrite the value of the con pointer, which afterwards points to no-go land. Use an integer with %d and your program works again. The fact that it worked by exchanging variable declarations just means that instead of the con pointer, you overwrote the ok flag. W. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9557