Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!news.uiowa.edu!uunet!europa.eng.gtefsd.com!howland.reston.ans.net!xlink.net!zib-berlin.de!informatik.tu-muenchen.de!hphalle4!behrenss From: behrenss@Informatik.TU-Muenchen.DE (Soenke Behrens) Subject: Bugs in ORCA/C 2.01 (list version 1.1) Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem) Organization: Technische Universitaet Muenchen, Germany Date: Mon, 6 Dec 1993 14:30:31 GMT Message-ID: Lines: 131 ================== Bugs in ORCA/C 2.0.1, v.1.1 ======================= Preface ======= These are bugs in ORCA/C 2.0.1 found by various users. All of these have already been reported to The Byteworks. The purpose of this document is to help you when programming the GS, so that by knowing about problems in your tools, you can work around them. It is NOT intended to help you bashing ORCA/C on grounds of it having bugs. Every product has bugs, and a C compiler is no exception. Note that only a few of the bugs listed here could be entitled "hardcore", the rest ranges from "annoying" to "mildly amusing". --> Support those that support you!! <-- Changes since v.1.0 =================== - Added the bug about mode "rb+". Thanks to the guy whose name I forgot :) who found it. - Added a section for devations from the ISO/C standard. The List ======== - If you declare a function as 'void foo(unsigned);' and define it as 'void foo(unsigned int bar)', you get a 'type conflict' error message. - Do NOT mix old-style function definitions with prototyped declarations. Passed parameters will be garbled if you attempt that. (I.e. don't do 'void foo (int *);', 'void foo (bar) int *bar;') - 'sscanf("foo","%d",&bar);' returns 1 as if it had correctly converted an integer. - 'sscanf("R A 3 0 4","%*[^PR]%c %c %d %d %d",&l,&q,&k,&m,&n),' returns 5. It should return 0, as '%*[^PR]' was not satisfied. - Defining a variable 'unsigned bar', assigning a value > INT_MAX to it, and casting that to (unsigned long) gives incorrect results. To work around this, define the variable as 'unsigned int bar' instead. - 'printf("%d != %d\n",0x8000U << 1, 1U << 16);' should print '0 != 0', it does print '0 != 1'. Bit-shifts are obviously sometimes handled incorrectly. - Open a file with mode "rb+". Read a character, step back one char with fseek, write one character, and close the file. You will notice that the file has not changed. The changes are written out correctly if you write more than just one character, though. - For the last bug, I guess I'll have to display some code: /* * this code shows two problems. The first while() loop acts more as * if its body were 'nedges[*(++sp)]++', not 'nedges[*sp++]++'. * The second while() loop produces an int math error. */ #include #include #pragma debug 25 int main (int argc, char *argv[]) { short *sp; short R_arg[6] = { 0, 1, 2, 3, 4, -1 }; static short S_arg[6] = { 0, 1, 2, 3, 4, -1 }; short nedges[5] = {0,0,0,0,0}; sp = S_arg; while (*sp >= 0) { printf ("sp: %p *sp: %d nedges[*sp]: %d\n",sp,*sp,nedges[*sp]); nedges[*sp++]++; } sp = R_arg; while (*sp >= 0) { printf ("sp: %p *sp: %d nedges[*sp]: %d\n",sp,*sp,nedges[*sp]); nedges[*sp++]++; } return (EXIT_SUCCESS); } Devations from ISO/C ==================== These are not bugs, but are areas where ORCA/C deters from the standard on purpose. - ORCA/C requires that functions that use consume all arguments they got before returning. It also requires that printf() and scanf() consume all arguments they get. Therefore, something like 'printf("%d",i,k);' is not legal with ORCA/C. - ORCA/C does not support tentative definitions. Thus, you may not use 'extern int foo = 0;' nor may you have two 'int foo;' definitions in the same source-file on the same scope. Conclusio ========= If you have discovered a bug in ORCA/C and you would like it included in this list, drop me e-mail at behrenss@informatik.tu-muenchen.de. December 1993, Soenke Behrens -- =========================================================================== More than silver, more than gold, I need ! behrenss@informatik. electricity. I need it for my dreams. ! tu-muenchen.de (RACTER) ! FIDO: 2:246/13 Soenke Behrens