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: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Compiler checking of String lengths during assignment (Newbie Question) Date: Fri, 16 Jan 2015 07:28:58 +0000 Organization: A noiseless patient Spider Message-ID: References: <77d434cc-00bc-4a2f-b50e-40736abdd2b2@googlegroups.com> <93725194-bf90-400f-844f-7d0d49adf030@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="8878eaae66d49f7d529ec3c7abf78fb7"; logging-data="7400"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tnqxZAw4UhE7ZOJeus2PFN/LeZiGEbGg=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:6GRfV9oHGSkyq40jzowvDowz1E8= sha1:JyP/NWKRpRpHtKnU7wb1uHoQAOM= Xref: news.eternal-september.org comp.lang.ada:24593 Date: 2015-01-16T07:28:58+00:00 List-Id: Jeffrey Carter writes: > On 01/15/2015 02:18 PM, Simon Wright wrote: >> >> As I think I've said before, with the same compiler (on Mac OS X, but >> I'd be _very_ surprised if that made a difference) I get warnings on >> all three lines. > > You don't have the code the OP compiled, since he didn't post > it. There's no telling what may appear between "begin" and the lines > in question in that code. As Duff showed, a null procedure call is > enough to eliminate the warning on the line using I. It was Adam, not Bob. Adam showed that procedure Main is Head : String (1..5) := "XXX_N"; i : Positive; Line : String := "12312312312312312"; procedure Nothing is null; begin i := 2; Nothing; -- <<<<< prevents the 3rd warning Head := "123"; Head := Line(1 .. 2); Head := Line(i+2 .. i+4); end Main; and, while I agree with you that the OP should have posted a compilable example that demonstrated the problem, the posted code had nothing between the assignment to i and the assignments to Head.