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: Thu, 15 Jan 2015 21:18:50 +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="29118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RJTPcDvA36V0F+EMgALDlonCVfzIUkKE=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:BmXZE3yy2RnGH2CYrEGIKL0LuKo= sha1:wWl6qOQ3n1RYsBGC/Qz6Pm/2zjo= Xref: news.eternal-september.org comp.lang.ada:24583 Date: 2015-01-15T21:18:50+00:00 List-Id: isaac1.0@gmail.com writes: > One is the compiler. Mine says GNAT GPL 2014 (20140331) and gcc is 4.7.4 > > gcc -c -I- -gnatA E:\Projects\Test\src\main.adb > main.adb:23:27: warning: wrong length for array of subtype of > "Standard.String" defined at line 9 > main.adb:23:27: warning: "Constraint_Error" will be raised at run time > main.adb:24:27: warning: too few elements for subtype of > "Standard.String" defined at line 9 > main.adb:24:27: warning: "Constraint_Error" will be raised at run time > > So I get the 2 warnings that are expected, but the 3rd one is > missed. I'm no compiler expert, but if you say it's difficult for the > compiler to sort out arithmetic logic like that, then maybe this is > the case. If a newer compiler is not showing the problem, then maybe > this has already been solved. 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.