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-Thread: 103376,3f92589f15917eec X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!feedme.ziplink.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Simple Warnings Needs Date: Wed, 23 Feb 2011 21:06:10 +0100 Organization: A noiseless patient Spider Message-ID: <87oc62wm6l.fsf@ludovic-brenta.org> References: <8aaf3582-0cc1-4c5f-ab85-eeb7ba569d9e@glegroupsg2000goo.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="WQDOJSO/kpPlXnNbibMqrw"; logging-data="31304"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pn3YS8IAp3efzUWMX6D61" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:bVuECYgJmmJaSo9KaqquDocBgLY= sha1:7LBvdxTltMg9QrUAkeBs5nyz/Lg= Xref: g2news2.google.com comp.lang.ada:18533 Date: 2011-02-23T21:06:10+01:00 List-Id: Rego writes: > I would like to know (in more details than gnat documentation) the > criticality of these warnings options: > > ** "-gnatwd" (Implicit dereferencing) > ** "-gnatwf" (Unreferenced formals) > ** "-gnatwh" (Hiding) > ** "-gnatwm" (Modified but unreferenced variables) > ** "-gnatwk" (Variables that could be constants) > > I mean, for instance, a code with several variables that could be > constants, even in local procedures is an ugly code, not clean, but > generally it's ok if works. But I just want to understand what kind of > other complications that code could get due to not fixing these type > of constructs. Someone once told me that it could bring out code > vulnerabilities, the binary app could become "hackeable", but he gave > not a deep explanation (so I cannot convince others about this). And I > did not find in ARM05 and gnat documentation. So, could someone give > me a hint? I don't think that "variables that could be constants" would make the program unsafe in the ways you describe. Instead, it could prevent the compiler from doing some optimizations. Bust the most important aspect of these warnings is that, if you exmine the sources at the place of the warning, you can discover bugs (it has happened to me several times). The other important aspect is long-term maintenance of your sources. In this context, if you decide not to fix the warnings, you basically guarantee that someone else, years after you, will have to investigate the warnings again. In addition to these considerations, "implicit dereferencing" could be important for safety-critical software, where the executable object code, not the sources, must be certified. It is important to be able to trace every instruction in the object code to a statement in the sources. Here, the compiler is warning you that it is emitting machine instructions that do not have an "obvious" source. "Unreferenced formals" and "Modified but unreferenced variables" could mean a design bug. If not, you can use pragma Unreferenced to document the fact that you've looked at this warning and decided it was not a bug (here again, think about long-term maintenance by many people). "Hiding" is sometimes forbidden outright by coding standards, so you want the compiler to warn you about that. -- Ludovic Brenta.