🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #41508

scanf bug in gcc 2.7.1 for Solaris 2.5

#41508
From: Ray Riggs
Date: Fri, 22 Mar 1996 00:00
44 lines
1592 bytes
I installed the gcc 2.7.1 binaries for Solaris 2.5 from

	opcom.sun.ca/pub/freeware

The following program appears to show a serious bug in scanf():

#include <stdio.h>
 
void main(void)
{
        int value=0;
 
        printf("Enter value: ");
        scanf("%d", &value);
        printf("Value=%d\n", value);
}

For input values >= 20, scanf appears to insert values of 10+(last digit).
For example:

	Input value	Output value
		5		5
		10		10
		15		15
		20		10
		21		11	
		22		12
		99		19
		512		12
		1000		10

and so on.  Is this fixed in 2.7.2?

Thanks,

Ray
--
/*****************************************************************************+
|                    Ray Riggs -- "El Jefe de Ordenadores"                    |
|      University of Manchester, Nuffield Radio Astronomy Laboratories,       |
|             Jodrell Bank, Macclesfield, Cheshire SK11 9DL, U.K.             |
|                        E-mail: R.Riggs@jb.man.ac.uk.                        |
|  Tel: +44 (0)1477-571321;  Fax: +44 (0)1477-571618;  Telex: 36149 JODREL G  |
+*****************************************************************************/
Technical Details
Message-ID: <RKR.96Mar22115551@gaia.jb.man.ac.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,31286070def2fafe,start
X-Google-Attributes: gid11318c,public
From: rkr@gaia.jb.man.ac.uk (Ray Riggs)
Subject: scanf bug in gcc 2.7.1 for Solaris 2.5
Date: 1996/03/22
Message-ID: <RKR.96Mar22115551@gaia.jb.man.ac.uk>
X-Deja-AN: 143813490
distribution: local
organization: Nuffield Radio Astronomy Labs, Jodrell Bank, U.K.
newsgroups: gnu.gcc.help