Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!nexus.uiowa.edu!hobbes.physics.uiowa.edu!moe.ksu.ksu.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!xlink.net!zib-berlin.de!informatik.tu-muenchen.de!behrenss From: behrenss@Informatik.TU-Muenchen.DE (Soenke Behrens) Subject: ORCA/C 2.0.1 bug list v.1.4 Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem) Organization: Technische Universitaet Muenchen, Germany Date: Wed, 29 Dec 1993 21:50:16 GMT X-Newsreader: TIN [version 1.2 PL2] Message-ID: <1993Dec29.215016.25121@Informatik.TU-Muenchen.DE> Lines: 177 ================== Bugs in ORCA/C 2.0.1, v.1.4 ======================= Last update 29/12/1993 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 bash 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 Peter Watson for reporting it. - Added a section for deviations from the ISO/C standard. Changes since v.1.1 =================== - Added the bug regarding .sym files and #endif. Thanks to Jay Krell for reporting it. Changes since v.1.2 =================== - Added the bug about not using '#' in conditional asm statements. Thanks to Matt Ackerett for reporting it. Changes since v.1.3 =================== - Added the bug about not using "static const struct foo bar [] =" - Added the bug about not typedef'ing an enum before defining it 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 - If you have an 'asm' statement with immediate addressing inside a block of conditional code that uses #ifdef, and the condition is not satisfied, you get an error "illegal character" about the '#' in the asm statement. Example, assuming `AppleIIGS` is NOT defined: #ifdef AppleIIGS void bar (void) { asm { lda #10 } } #endif - If you have a struct foo (with two ints, in this case), and you define an array of it like: static const struct foo bar[] = { { 0, 0}, { 1, 1}, }; ORCA/C will not be happy. Use "static struct foo bar[] = {" instead. - ORCA/C does not like you to typedef an enum before you define it. Do it the other way round. - 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 -- =========================================================================== Ich habe den Todesloewen gesehen -- er ! Soenke Behrens wacht vor der Grube der Namenszuege. ! Tumblinger 54/205 (Pieter Gefjon) ! 80337 Muenchen