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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Compiler checking of String lengths during assignment (Newbie Question) Date: Fri, 09 Jan 2015 17:18:40 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <77d434cc-00bc-4a2f-b50e-40736abdd2b2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Sat, 10 Jan 2015 00:18:15 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="9d3e8459fcff41835e7b68eb9f2a14bb"; logging-data="26877"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yvNw6QyQ1KlXiFUBxVbH2+91mXl3D1o8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: <77d434cc-00bc-4a2f-b50e-40736abdd2b2@googlegroups.com> Cancel-Lock: sha1:loc2pznaokamEQrxRIawzHziZb4= Xref: news.eternal-september.org comp.lang.ada:24519 Date: 2015-01-09T17:18:40-07:00 List-Id: 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