comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Compiler checking of String lengths during assignment (Newbie Question)
Date: Fri, 09 Jan 2015 17:18:40 -0700
Date: 2015-01-09T17:18:40-07:00	[thread overview]
Message-ID: <m8pr45$q7t$1@dont-email.me> (raw)
In-Reply-To: <77d434cc-00bc-4a2f-b50e-40736abdd2b2@googlegroups.com>

On 01/09/2015 03:50 PM, isaac1.0@gmail.com wrote:
> 
> The first 2 cases produces an error during the build, as expected, because
> Head is known to be length of 5 and I'm assigning something of a different
> length.

They might produce warnings, but not errors, unless you've told the compiler to
treat warnings as errors.

> The 3rd assignment there does NOT produce an error, no warning no nothing
> even though this clearly violates the same check.

Have you tried compiling with -gnatwa?

> What does happen is that at runtime the execution is incorrect. It doesn't
> even terminate in a horrible disaster (which would be preferable). The full
> program actually just reads a text file (for now) and in this case because
> the assigned length is incorrect, it just reads a few lines then bails
> claiming unable to read the text file.

Do you have an exception handler?

> Aren't Ada compilers supposed to prevent stupid errors like this? Or is there
> some user stupidity here that I'm not seeing...?

Unless you give us a complete program, the options used when building it, the
exact messages output when run, and what you expected the result of running it
to be, we can't tell.

-- 
Jeff Carter
"Sons of a silly person."
Monty Python & the Holy Grail
02

  parent reply	other threads:[~2015-01-10  0:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 22:50 Compiler checking of String lengths during assignment (Newbie Question) isaac1.0
2015-01-09 23:10 ` Simon Wright
2015-01-09 23:20   ` Stefan.Lucks
2015-01-10 12:43     ` Brian Drummond
2015-01-09 23:53 ` Shark8
2015-01-10  0:18 ` Jeffrey Carter [this message]
2015-01-10  1:48 ` Adam Beneschan
2015-01-10 10:03 ` Pascal Obry
2015-01-10 10:54 ` Simon Wright
2015-01-15 20:44 ` isaac1.0
2015-01-15 21:18   ` Simon Wright
2015-01-15 22:30     ` Jeffrey Carter
2015-01-15 22:32     ` Jeffrey Carter
2015-01-16  7:28       ` Simon Wright
2015-01-16 15:44         ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox