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!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: CONSTRAINT ERROR? access check failed Date: Thu, 01 Mar 2018 17:26:07 +0000 Organization: A noiseless patient Spider Message-ID: References: <39fc7bbf-77e8-4342-9af7-68cb5e9acb8a@googlegroups.com> <1e744a67-b2bf-437c-b503-8bd4c13da655@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="4cc54f234a1bf931e5c37fdebf83263c"; logging-data="19993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ow1mNo9aMphudwGhORmoZ+vCjKk0g8og=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:kIxvBthhujNlEfL2S/RfyokXxsI= sha1:63d9XeaYfLs7IuMs1Gjfuug/X4U= Xref: reader02.eternal-september.org comp.lang.ada:50755 Date: 2018-03-01T17:26:07+00:00 List-Id: Mehdi Saada <00120260a@gmail.com> writes: > Work finished ! Thank you. > But I would like to know why I get a warning at compile time with > type Link (Num : LINE_NUMBER := 0; Length : NATURAL := 0) is > record > NEXT : access LINK := null; > Line : String (1 .. Length) := (1..Length => ' '); > end record; > As if it could cause a stack overflow (was written as is). Yet I don't get at each compilation, surprisingly. Because Length could be Natural'Last which would make Line large enough to break the stack on any machine likely to be available to you. Do you really need the default values? If you have defaults, then creating an object of the type without specifying values for the discriminants makes the discriminants changeable (by whole-record assignment), so that sufficient space has to be reserved for the largest possible record. Without defaults, you have to supply discriminants when you create an object (the discriminants then can't be changed, but will that matter?).