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: border2.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!feeds.phibee-telecom.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Compiler checking of String lengths during assignment (Newbie Question) Date: Fri, 09 Jan 2015 23:10:20 +0000 Organization: A noiseless patient Spider Message-ID: References: <77d434cc-00bc-4a2f-b50e-40736abdd2b2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="aa3eb2c524c8db378c1a383f7730f657"; logging-data="12623"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/f9+T0fQEsYQaOOrVMra0fl908PqSHYR8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:OVcceEP1nRcaSOGcsC9YKd+lmcI= sha1:Wfr4vmaZBC75BjbCaBC7W+idjEE= Xref: number.nntp.giganews.com comp.lang.ada:191820 Date: 2015-01-09T23:10:20+00:00 List-Id: isaac1.0@gmail.com writes: > 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. > The 3rd assignment there does NOT produce an error, no warning no > nothing even though this clearly violates the same check. > > 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. This sounds as if it might be related to GCC PR ada/61466[1]. Are you optimising? > Aren't Ada compilers supposed to prevent stupid errors like this? Or > is there some user stupidity here that I'm not seeing...? Sometimes compilers do have bugs. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61466