Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mcvax!eurifb!euraiv1!aiv From: aiv@euraiv1.UUCP (Eelco van Asperen) Newsgroups: comp.sys.ibm.pc Subject: Turbo C bug Message-ID: <582@euraiv1.UUCP> Date: Mon, 3-Aug-87 09:21:41 EDT Article-I.D.: euraiv1.582 Posted: Mon Aug 3 09:21:41 1987 Date-Received: Tue, 4-Aug-87 02:08:33 EDT Organization: EUR/EF/AIV,PObox 1738,Rotterdam,Neth. Lines: 94 Keywords: Turbo C;bugs I think I've found 2 more bugs in Turbo C; the first one is about the use of hexadecimal character constants. According to the manual (p131, User's Guide): "..., modern C allows you to declare character constants in hex notation. The general format is '\xDD', where DD represents one or two hexadecimal digits (0..9, A..F). These escape sequences can be directly assigned to char variables, or they can be embedded in strings". So, the following test program should run without problems; main() { char wrong[] = "test:\x40abcd"; char right[] = "test:\x040abcd"; printf("wrong: '%s'\n\nright: '%s'\n",wrong,right); } Alas, the wrong-string is printed as 'test:\nbcd' so that 'bcd' is printed on the next line. Apparently a 3 digit hex-number is expected of which the first digit is not used hence the '\n' (=0x0A). The second bug is about interrupt-procedures; Turbo C enables you to prefix a procedure with the interrupt-keyword and the result will be that all registers are saved upon entry and restored at exit. Now, if you compile such a procedure with 'Test Stack Overflow On', then Turbo C will happily add a check for stack-overflow just after saving the registers; naturally, this will usually crash your program and most likely your PC as well. Example C-program: void interrupt handler(void) { /* nop */ } main() { printf("demo demo demo\n"); } Assembler code produced by 'tcc -c -S -N bug.c': ; Line 3 _handler proc far push ax push bx push cx push dx push es push ds push si push di push bp mov bp,dgroup mov ds,bp cmp word ptr dgroup:___brklvl,sp ;!! ERROR !! jb @2 call far ptr overflow@ @2: ; Line 4 ; Line 5 @1: pop bp pop di pop si pop ds pop es pop dx pop cx pop bx pop ax iret _handler endp Of course, you can avoid this by putting the interrupt-handler in a separate file that you compile without the check; however, this approach will not work with the integrated environment (tc) I like to use for development. I'ld like to emphasize that I like Turbo C a *lot* and that any product that sells like Turbo C (>100K copies), is bound to generate a lot more bug reports that other, less successfull, ones. Eelco van Asperen. -----------------------------------------+------------------------------------- Erasmus University Rotterdam |uucp:mcvax!{eurifb,olnl1}!euraiv1!aiv Fac. of Economics, Computer Science Dept.|earn:asperen@hroeur5 PO.box 1738 / 3000 DR Rotterdam | T H E N E T H E R L A N D S |(this space intentionally left blank) -----------------------------------------+-------------------------------------