Prev: naming, was Re: Design problem: generic package vs tagged subtype
Next: ANN: GtkAda contributions v2.7
From: Markus Schoepflin on 2 Jul 2010 05:44 Am 02.07.2010 11:30, schrieb Stephen Leake: > Markus Schoepflin<nospam(a)no.spam> writes: [...] >> Is this possible with gnat without turning all warnings into errors? > > Just out of curiosity, why not treat all warnings as errors? > > gnat is a very good compiler; the warnings it produces should be taken > seriously. I would love to, but I'm dealing with a multi-million LOC legacy code base of Ada 83 in maintenance mode, which produces quite a large number of warnings. I neither have the time nor the resources available to fix all of them, nor am I allowed to do so. But if the compiler already knows that there will be a constraint error at runtime, I would have liked the compilation to fail. > I have a policy of always eliminating all warnings. Sometimes that means > redesigning the code, which in the end turns out to be a good thing. > > There are times when the only way to eliminate a warning is to use > pragma Warings (Off), or give a file-specific compiler option in a > project file. But that is rare, and the benefits from otherwise > eliminating warnings is large. Markus
From: Randy Brukardt on 2 Jul 2010 16:17 "Markus Schoepflin" <nospam(a)no.spam> wrote in message news:i0kcdn$g44$1(a)nntp.ilk.net... .... > I neither have the time nor the resources available to fix all of them, > nor am I allowed to do so. But if the compiler already knows that there > will be a constraint error at runtime, I would have liked the compilation > to fail. Keep in mind that such a message may occur in cases where there is no actual problem. That can often happen if you have code that is conditional on constants. To take an extreme example, if you have: Max_Items := constant := 0; and then the code is: if Max_Items /= 0 then Average := Float(Count)/Float(Max_Items); -- (1) else Average := 0.0; end if; The code at (1) would raise Constraint_Error if it was executed, but of course it can never be executed. If you change the warning to an error here, you won't be able to compile the code without removing or changing the expression at (1), and that would cause problems if/when Max_Items is set to a different value. Randy.
From: Georg Bauhaus on 2 Jul 2010 16:33 On 7/2/10 11:44 AM, Markus Schoepflin wrote: > I neither have the time nor the resources available to fix all of them, > nor am I allowed to do so. But if the compiler already knows that there > will be a constraint error at runtime, I would have liked the > compilation to fail. (I can't think of a way to do this without annotating each occurrence in the source program: some programs might want the constraint_error to be produced for whatever reason ...) Anyway, grep has helped me scan traces of output and trigger actions accordingly, that should be a workaround. I understand GPS is programmable, so maybe the log console has hooks this sort of special case?
From: Stephen Leake on 3 Jul 2010 04:01 Markus Schoepflin <nospam(a)no.spam> writes: > Am 02.07.2010 11:30, schrieb Stephen Leake: > >> Markus Schoepflin<nospam(a)no.spam> writes: > > [...] > >>> Is this possible with gnat without turning all warnings into errors? >> >> Just out of curiosity, why not treat all warnings as errors? >> >> gnat is a very good compiler; the warnings it produces should be taken >> seriously. > > I would love to, but I'm dealing with a multi-million LOC legacy code > base of Ada 83 in maintenance mode, which produces quite a large > number of warnings. > > I neither have the time nor the resources available to fix all of > them, nor am I allowed to do so. I can understand not changing design in a maintenance situation, but adding 'pragma Warnings (off)' in places ought to be ok. Still, it can be a lot of work. > But if the compiler already knows that there will be a constraint > error at runtime, I would have liked the compilation to fail. Using GNAT project files, you can specify -gnatwe for particular files: for Switches ("sal-gen-alg.adb") use Standard_Common.Compiler'Default_Switches ("Ada") & Standard_Common.Compiler.Release_Switches & ("-gnatwe"); Not quite what you want, but it might help. -- -- Stephe
From: Dmitry A. Kazakov on 3 Jul 2010 06:00 On Fri, 02 Jul 2010 22:33:25 +0200, Georg Bauhaus wrote: > On 7/2/10 11:44 AM, Markus Schoepflin wrote: > >> I neither have the time nor the resources available to fix all of them, >> nor am I allowed to do so. But if the compiler already knows that there >> will be a constraint error at runtime, I would have liked the >> compilation to fail. > > (I can't think of a way to do this without annotating each > occurrence in the source program: some programs might want > the constraint_error to be produced for whatever reason ...) Yep, it is called contracted exceptions! BTW. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: naming, was Re: Design problem: generic package vs tagged subtype Next: ANN: GtkAda contributions v2.7 |