Mail Archives: djgpp/1997/06/20/19:51:29
From: | geirt AT powertech DOT no (Geir Thomassen)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Error when optimising ??
|
Date: | Thu, 19 Jun 1997 13:57:33 GMT
|
Organization: | Jotron Electronics
|
Lines: | 61
|
Message-ID: | <5obdsi$5fq$1@troll.powertech.no>
|
NNTP-Posting-Host: | gw1-1.sandefjord.no.powertech.net
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I have a small program that behaves differently
when optimised. Why ?? Am I using sprintf wrong ??
Compiler bug ??
I am using plain DJGPP v2.01, no PGCC. I beleve the program
worked under DJGPP 2.00. (At least I didn't notice any
problems with my code before I upgraded..)
Here is the source:
------------------
#include <stdio.h>
int main (int argc, char *argv[])
{
int n;
int r;
unsigned long o;
if (sscanf ("1020304050", "%02X%04lX%02X", &n, &o, &r) != 3)
{
printf("fscanf failed\n");
return -1;
}
printf("n=%X (should be 10)\n",n);
return 0;
}
----------------------------
This is what happends (in a win95 shell):
C:\Usr\tst>gcc -Wall tst.c -o tst.exe
C:\Usr\tst>tst
n=10 (should be 10)
C:\Usr\tst>gcc -Wall -O tst.c -o tst.exe
C:\Usr\tst>tst
n=0 (should be 10)
C:\Usr\tst>
----------------------------
Any idea ??
Geir
| Geir Thomassen, | geirt AT powertech DOT no |
| R&D Engineer, electronics (MSc) | LA7HFA, qrv 2.45GHz :-) |
| | |
| Jotron Electronics a.s. | Phone +47 33139700 |
| P.O. Box 85 | Fax +47 33126780 |
| N-3280 Tjodalyng | Priv +47 33458231 |
| Norway | Telex 21715 TRON N |
| |
| 9.81 m/s^2 - the best way to accelerate a PC ! |
- Raw text -