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,1d321b3a6b8bcab2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-25 15:18:51 PST Newsgroups: comp.lang.ada Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!gw1.att.com!fnnews.fnal.gov!uwm.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!agate!dog.ee.lbl.gov!newshub.nosc.mil!news!sampson From: sampson@nosc.mil (Charles H. Sampson) Subject: Re: "Subtract C, add Ada" Message-ID: <1995Jan25.231851.20858@nosc.mil> Sender: news@nosc.mil Organization: Computer Sciences Corporation References: <3fvqj5$ofr@miranda.gmrc.gecm.com> Date: Wed, 25 Jan 1995 23:18:51 GMT Date: 1995-01-25T23:18:51+00:00 List-Id: In article <3fvqj5$ofr@miranda.gmrc.gecm.com>, R.A.L Williams wrote: >In article <3feevh$615@gnat.cs.nyu.edu> Robert Dewar wrote: >: ... there are lots of things that Ada people take for granted that cannot >: be checked in C, there just isn't enough information. C has no separation >: of scalar types, no ranges on scalar types, and the ubquitous use of >: pointers, and their similarity to arrays means that sophisticated aliasing >: analysis is required to even approximate the type checking that occurs >: in the context of access types in Ada. There are many other examples. > >Ranges - no, but my Microsoft C compiler certainly *does* warn me when I > - mix signed and unsigned integers (of course, Ada83 doesn't have unsigned) > - assign the result of 'long' expressions to shorts or chars etc. > - perform 'unchecked conversion' between integers and pointers What is it warning you about? All three of these are reasonable things to do (o. k., the third is a little shady), so is getting a warn- ing from the compiler about them really beneficial. Typically, a pro- liferation of such noisy warnings can cause the programmer to overlook an important compiler message. I'm not sure what you mean by "mixing" signed and unsigned integers, but if they come from the same base type, why shouldn't they be "mixed"? They are just integers, after all. If you mean assigning a value from a signed (sub)type to an object of an unsigned (sub)type, then Ada will warn you about it, by means of an exception, when you do it wrong but will be silent as long as you do it right. The same thing will happen if you assign a value from a (sub)type having a big range to an object of a (sub)type having a smaller range, or to an object of type Character (after you've done all the necessary ex- plicit conversions). Finally, if you want to perform an unchecked conversion from integer to pointer, or vice versa, in Ada you have to use a syntax that basically tells the compiler that you know what you're doing. I don't know about you, but I sure wouldn't look very kindly on a compiler that warns me in such a case that I might not know what I'm doing.