sysop@pro-generic.cts.com (Matthew Montano) (10/19/89)
I found an interesting bug in ORCA/C's compiler today: Try placing a return on a line by itself without the terminating ";" for the line. If the following line is a simple assignment operator (x=10 etc.) then it will compile and work correctly without the ";", with a flow control operator after it (while, for etc.) it will error out on the compile. Whether this is related to this problem, I am unsure, but this program below does NOT work. No matter what I try, it crashes into the monitor on the return in all occurences under finddevice. --- #pragma keep "fd" #include <gsos.h> main() { word requestid; int devid; struct DInfoRec myDInfo; requestid = 0x0009; devid = finddevice(requestid); printf("Correct device (with ID requested):%d",devid); exit(); } finddevice(requestid) word requestid; { struct DInfoRec myDInfo; int myerror, miscint; printf("requested id %d\n", requestid); miscint = requestid; /* requestid looses value as soon as we exit */ /* finddevice with DInfo(blah) */ myerror = 0; myDInfo.pCount = 10; myDInfo.devNum = 1; while (myerror == 0) { printf("Checking %d\n", myDInfo.devNum); DInfoGS(&myDInfo); if (toolerror()) { printf("Toolerror %x",toolerror()); myerror = 1; return(0); } printf("DevID:%x DevNum:%d\n",myDInfo.deviceID, myDInfo.devNum); if (myDInfo.deviceID == miscint) { printf("Found device!"); return(myDInfo.devNum); } myDInfo.devNum++; } } --- It simply crashes.. every single time, even if I want to return nothing to the main() subprogram. If I place a return before the DInfo call, it returns correctly. Is there something I should call before I place the call to DInfo within the function to allow it to function correctly? I do believe that the ORCA/C compiler is missing many checks for error checking, assuming the perfect programmer is a real poor assumption. I used the first version of Turbo C on the Messy-Dos machines and had nearly all my poor thinking flagged even before it thought about linking it! I must admit that the documentation is decent and the price was resonable, but it has to work.. Is APW C worth the $25 more? UUCP: crash!pro-generic!sysop ARPA: crash!pro-generic!sysop@nosc.mil INET: sysop@pro-generic.cts.com
gwyn@smoke.BRL.MIL (Doug Gwyn) (10/20/89)
In article <8910190700.AA14944@trout.nosc.mil> sysop@pro-generic.cts.com (Matthew Montano) writes: > I found an interesting bug in ORCA/C's compiler today: > Try placing a return on a line by itself without the terminating ";" for the >line. If the following line is a simple assignment operator (x=10 etc.) then >it will compile and work correctly without the ";", with a flow control >operator after it (while, for etc.) it will error out on the compile. I recently reviewed the archived messages about ORCA/C on Genie, and was quite disappointed to find most of them in this vein -- in other words, somebody not knowing how to use C. In fact ORCA/C is doing the right thing here. That's not to say it doesn't have bugs, but unfortunately most of what Mike Westerfield seems to have been tracking down are user misunderstandings about C, not actual bugs. >... No matter what I try, it crashes into the monitor on the return >in all occurences under finddevice. ORCA/C, due to its function linkage design, is quite unforgiving when you misuse functions (i.e. have parameter/argument type mismatches or other conformability errors). I don't know for sure what is causing the particular problem you reported, but keep that in mind. For example, possibly ORCA/C is not happy that you failed to return a value in your int-valued function finddevice().