Re: Ada checks suppression thanks to compilation options and Ada conformity
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sat, 10 Nov 2007 14:00:05 -0800
Dennis Lee Bieber <wlfraed@xxxxxxxxxxxxx> writes:
[...]
Well... from my lowly perspective...
1) One text book describes "pragma" as a "directive to the
compiler"... Compilation options can also be considered "directives to
the compiler"
Sure, but pragmas are defined by the language; compilation options are
not.
2) Many of my Ada texts tend to treat "pragma" as a "suggestion" for
the compiler -- and indicate that compilers are allowed to ignore
pragmas for which they are not coded
Implementations are allowed to define their own pragmas. If a
compiler doesn't recognize the name of a pragma, it must issue a
warning, and the pragma has no effect.
But this doens't apply to pragma Suppress, which is defined by the
language; for that, you have to look at what the standard specifically
says about pragma Suppress. A pragma Suppress gives the compiler
permission to omit the specified check(s). It doesn't require it to
do so, and a conforming compiler could ignore pragma Suppress
altogether.
The purpose is not to allow operations that would raise exceptions;
it's to allow faster code to be generated, based on the assumption
that the exceptions would not have been raised. In other words, using
pragma Suppress means that the burden of avoiding overflows and other
errors is on the programmer rather than on the compiler.
3) The absence of a "pragma X" does not imply "pragma NOT-X" (eg,
absence of "pragma Suppress" does not imply "pragma Suppress NONE"
Yes, it does. The language standard requires certain checks to be
performed. This requirement applies *unless* pragma Suppress is used.
If you don't use pragma Suppress (or some implementation-defined
pragma with similar semantics) and a required check is not performed,
then the implementation is failing to conform to the standard.
This isn't necessarily a bad thing. If a compiler provides a
command-line option to suppress all checks, that can be quite useful;
it's easier than modifying the source every time you want to disable
or enable checks. But a compiler with such an option specified is not
a standard-conforming Ada compiler.
There is a counter-argument to this. The input to the compiler is one
or more compilation units; the standard doesn't specify how a
compilation unit is represented. It could be argued that, if you
specify a compiler command-line option to suppress all checks, it
causes the compilation unit to consist of the specified source file
*plus* a "pragma Suppress(All_Checks);" at the top.
Conclusion: Always read the documentation for the compiler in use.
Absolutely.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- References:
- Ada checks suppression thanks to compilation options and Ada conformity
- From: Christophe TRAVERS
- Ada checks suppression thanks to compilation options and Ada conformity
- Prev by Date: Re: A scary story from the real world.
- Next by Date: Re: ada compiler?
- Previous by thread: Re: Ada checks suppression thanks to compilation options and Ada conformity
- Next by thread: I think I'm going to learn something
- Index(es):
Relevant Pages
|