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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.43.56.79 with SMTP id wb15mr14168102icb.9.1420843817412; Fri, 09 Jan 2015 14:50:17 -0800 (PST) X-Received: by 10.50.79.228 with SMTP id m4mr94853igx.8.1420843817325; Fri, 09 Jan 2015 14:50:17 -0800 (PST) Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!h15no1735554igd.0!news-out.google.com!h6ni1038igv.0!nntp.google.com!h15no1735552igd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 9 Jan 2015 14:50:16 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=207.102.98.187; posting-account=QZXBrgoAAADhgHRaMWbEzK_0LI2JYo5W NNTP-Posting-Host: 207.102.98.187 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <77d434cc-00bc-4a2f-b50e-40736abdd2b2@googlegroups.com> Subject: Compiler checking of String lengths during assignment (Newbie Question) From: isaac1.0@gmail.com Injection-Date: Fri, 09 Jan 2015 22:50:17 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:191819 Date: 2015-01-09T14:50:16-08:00 List-Id: Maybe this is obvious to the experts, but I'm new to Ada. I'm using the Libre GNAT GPS 2014. I've a program that looks roughly like t= his: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D procedure Main is Head : String (1..5) :=3D "XXX_N"; i : Positive; Line : String :=3D "12312312312312312"; =20 begin . . . i :=3D 2; Head :=3D "123"; Head :=3D Line(1 .. 2); Head :=3D Line(i+2 .. i+4); . . . end Main; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 e= ven 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 cla= iming unable to read the text file. Aren't Ada compilers supposed to prevent stupid errors like this? Or is the= re some user stupidity here that I'm not seeing...? Thanks, Isaac