I'm developing a large project using the Ada language (around 10000 lines of only-code). During the use of the contract-base programming (Ada-2012 features like pre, post conditions, type invariants etc.) I find that when an Assertion or a condition goes wrong, the program terminates, hence the assertion has been checked, but without any messsage about the type and the place where the error is.
Then, to figure out if the problem was about the ada 2012 features, or instead, about any runtime error, I tried to insert a simple runtime error that doesn't concern with Assertions/Contracts: a division by zero.
declare
X : Integer := 1 - 1;
Y : Integer := 1 / X;
begin
null;
end;
and in this case the compiler advises me that will be raised an exception but at runtime the program completely terminates but anything is printed out. Hence the problem comes out with all kind of runtime check failure, not only those that concern with Assertions.
Moreover I tried to make a new project with only few lines of code to try a simple runtime error (as before division by zero) and also preconditions and Assertion failure. In this small project the program print on the consolle all the errors. Only the large project is affected by the problem.
My question is where could be the problem? Why this affects only my project and not the simple, just created, one? Could be there options that inhibit the printing of runtime check failure? I'm running on XUbuntu 13.10. I'm using the latest (2013) gpl version of gnat, gps, gnatcoll, aws, polyorb. I'm compiling with switches "-gnata" and "-gnat12".
Thanks very much for the help.
If you want to use GNAT as a proper Ada compiler, you should as an absolute minimum pass it these arguments:
Personally I have written this project file, which I use to set my preferred arguments to GNAT:
-- O mighty Emacs, please use -*- Ada -*- mode in this lowly file.
abstract project Ada_2012 is
for Source_Dirs use ();
package Builder is
for Default_Switches ("Ada")
use ("-m");
end Builder;
package Compiler is
for Default_Switches ("Ada")
use ("-fstack-check", -- Generate stack checking code (part of Ada)
"-gnata", -- Enable assertions (part of Ada)
"-gnato13", -- Overflow checking (part of Ada)
"-gnatf", -- Full, verbose error messages
"-gnatwa", -- All optional warnings
"-gnatVa", -- All validity checks
"-gnaty3abcdefhiklmnoOprstux", -- Style checks
"-gnatwe", -- Treat warnings as errors
"-gnat2012", -- Use Ada 2012
"-Wall", -- All GCC warnings
"-O2"); -- Optimise (level 2/3)
end Compiler;
end Ada_2012;
I "with" this file in all my Ada (2012) project files to have easy access to my standard settings. Here is an example (from http://repositories.jacob-sparre.dk/lego-tools):
-- O mighty Emacs, please use -*- Ada -*- mode in this lowly file.
with "ada_2012";
project LEGO_Tools is
for Source_Dirs use ("src/",
"../../Mathematics_and_Statistics/**");
for Main use ("build_mpd_file",
"fractal_landscape",
"outline_boundaries",
"pgm_to_ldraw",
"split_ldraw_file");
package Builder renames Ada_2012.Builder;
package Compiler renames Ada_2012.Compiler;
for Object_Dir use "obj/";
for Exec_Dir use "bin/";
end LEGO_Tools;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With