Article 1610 of comp.sys.apple2.programmer: Newsgroups: comp.sys.apple2.programmer Path: caen!uwm.edu!cs.utexas.edu!uunet!zib-berlin.de!informatik.tu-muenchen.de!behrenss From: behrenss@Informatik.TU-Muenchen.DE (Soenke Behrens) Subject: ORCA/C 2.01 bugs, version 1.2 Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem) Organization: Technische Universitaet Muenchen, Germany Date: Sun, 12 Dec 1993 12:27:47 GMT Message-ID: <1993Dec12.122747.29256@Informatik.TU-Muenchen.DE> Lines: 140 ================== Bugs in ORCA/C 2.0.1, v.1.2 ======================= 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 deviations from the ISO/C standard. Changes since v.1.1 =================== - Added the bug regarding .sym files and #endif. I think I will have to organize things better ... I was positive I had written down the name of the guy who reported it this time. *Sigh*. I feel sheepish. 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. - If the last statement that goes into creating the .sym file is #endif, and the .sym file already exist, ORCA/C will complain about "no matching #if for this #endif". Example: #ifdef APPLE2 #include #endif - 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); } Deviations 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