From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,32cfbb718858528b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-07 21:46:19 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn1feed!worldnet.att.net!204.127.198.204!attbi_feed4!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail From: "SteveD" Newsgroups: comp.lang.ada References: <3D002D11.CC706952@adaworks.com> <4519e058.0206071148.9b87acf@posting.google.com> <3D0116F3.7254E263@despammed.com> <3D018106.6080004@worldnet.att.net> Subject: Re: Commercial C To Ada 95 compiler X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: NNTP-Posting-Host: 12.225.227.101 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc52.ops.asp.att.net 1023511578 12.225.227.101 (Sat, 08 Jun 2002 04:46:18 GMT) NNTP-Posting-Date: Sat, 08 Jun 2002 04:46:18 GMT Organization: AT&T Broadband Date: Sat, 08 Jun 2002 04:46:18 GMT Xref: archiver1.google.com comp.lang.ada:25502 Date: 2002-06-08T04:46:18+00:00 List-Id: "Jim Rogers" wrote in message news:3D018106.6080004@worldnet.att.net... > SteveD wrote: > [snip] > > You may be very wrong here. Ada compilers tend to identify many more > errors at compile time than C compilers. This means that code > which compiles without error on a C compiler, when directly translated > to Ada, will may not compile. > > One simple example is indexing past the end of an array. > C compilers simply will not catch this problem. Ada compilers will. In fact this is not an error in C. Programs can (and do) intentionally index past the end of arrays. I have seen C code that allocates memory dynamically and uses array access to reference the memory. It is nearly impossible to distinguish these cases. > On the whole, direct translation may not be possible. C uses > implicit conversion between integer and floating point types. > Ada provides no such implicit conversion. You will at least need > to make all implicit C conversions explicit in Ada. I disagree, direct translation is possible. The order of conversions in C is explicitly defined. The translation would have to turn these implicit conversions into explicit conversions. Again, a review of the translated could may reveal surprises. > Another incompatibility is trying to reference the control > variable in a "for" loop outside the scope of the "for" loop. > This is impossible in Ada and not uncommon in C. The C compiler > will allow this. The Ada compiler will not. In this case a direct translation should translate the for loop to a while construct. For a direct translation the generated code must behave exactly the same as the original code. > Your example of "direct" translation of a C for loop with a null > body to an Ada while loop is a good approximation of the problem, > but not, IMHO, a direct translation. A direct translation would have > the C code also using a while loop. Ada for loops simply cannot > demonstrate this error. Any attempt to do so will create a > compiler error. You miss my point. The translation is from C to Ada. I can't change the C code, I'm translating it. In my example the C code had an error, the fact that the for loop was empty was missed in the original code. This shows up readily in the Ada code. BTW: I'm not saying I would want a C to Ada translator. I'm just saying that if someone said they wanted one, I can understand their reasoning. SteveD > > Jim Rogers >