From: Message-Id: <200304301100.h3UB0RBW010425@speedy.ludd.luth.se> Subject: Re: Yet another try on nan in strto{f,d,ld} In-Reply-To: <9743-Mon28Apr2003063327+0300-eliz@elta.co.il> "from Eli Zaretskii at Apr 28, 2003 06:33:28 am" To: djgpp-workers AT delorie DOT com Date: Wed, 30 Apr 2003 13:00:27 +0200 (CEST) X-Mailer: ELM [version 2.4ME+ PL78 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-MailScanner: Found to be clean Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk According to Eli Zaretskii: > > From: > > Date: Sun, 27 Apr 2003 19:03:09 +0200 (CEST) > > > > Uhoh! That was run in WINDOZE 98. In plain DOZE I get SIGFPE. Is that > > bad? > > It's not good. I think we should replace the FP assignment with an > assignment of a long long, or with a memcpy, then. From what I can see the problem is in printf(), not in any assignments strtof() does. I add /* Fault on FPU exception. */ _control87(0, 0x3f); printf("FPU CW: 0x%08x.\n", _control87(0, 0)); to the start of main in t-strtof.c (renamed to tstrtof2.c) and when run I get a crash A:\>tstrtof2 FPU CW: 0x00000340. float tests: Exiting due to signal SIGFPE Floating Point exception at eip=0000b9b1, x87 status=b1a0 eax=000917ac ebx=00092c2b ecx=0000000c edx=00090f40 esi=000918ad edi=00000006 ebp=0009171c esp=00091718 program=A:\TSTRTOF2.EXE cs: sel=00bf base=00116000 limit=0009ffff ds: sel=00c7 base=00116000 limit=0009ffff es: sel=00c7 base=00116000 limit=0009ffff fs: sel=009f base=000051d0 limit=0000ffff gs: sel=00d7 base=00000000 limit=0010ffff ss: sel=00c7 base=00116000 limit=0009ffff App stack: [00092dc4..00012dc4] Exceptn stack: [00012d44..00010e04] Call frame traceback EIPs: 0x0000b9b1 __modfl+33 0x000090ed cvtl+417 0x00008632 _doprnt+1774 0x0000379e sprintf+46 0x00001d49 main+189, file tstrtof2.c, line 141 0x0000368c __crt1_startup+204 A:\>symify -o tstrtof2.sym tstrtof2.exe A less complex example, nan_ass2.c: #include #include #include #include int main(void) { double d; long double ld; /* Fault on FPU exception. */ _control87(0, 0x3f); printf("FPU CW: 0x%08x.\n", _control87(0, 0)); d = NAN; printf("d = %.20g.\n", d); ld = NAN; printf("ld = %.20Lg.\n", ld); return(EXIT_SUCCESS); } generates A:\>nan_ass2 FPU CW: 0x00000340. Exiting due to signal SIGFPE Floating Point exception at eip=00007738, x87 status=c581 eax=00094581 ebx=00000014 ecx=00000000 edx=00001629 esi=00000014 edi=00011d94 ebp=00091cdc esp=000908b4 program=A:\NAN_ASS2.EXE cs: sel=00bf base=00116000 limit=0009ffff ds: sel=00c7 base=00116000 limit=0009ffff es: sel=00c7 base=00116000 limit=0009ffff fs: sel=009f base=000051d0 limit=0000ffff gs: sel=00d7 base=00000000 limit=0010ffff ss: sel=00c7 base=00116000 limit=0009ffff App stack: [00091d94..00011d94] Exceptn stack: [00011d14..0000fdd4] Call frame traceback EIPs: 0x00007738 _doprnt+1652 0x00002c2c printf+28 0x00001684 main+72, file nan_ass2.c, line 18 0x00002bbc __crt1_startup+204 A:\>symify -o nan_ass2.sym nan_ass2.exe One weird thing, line 18 is "ld = NAN;", but the crash was in printf/_doprnt? Right, MartinS