From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Performance of records with variant parts Date: Wed, 24 Mar 2021 00:27:19 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <07a56dcc-9e17-49b2-a980-3a5a2d265cedn@googlegroups.com> <23dcce3e-0db1-4417-a5d1-a05f03f74464n@googlegroups.com> <302c2e86-2379-46e0-b1f7-d69e7e14f9cfn@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 23 Mar 2021 23:27:19 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="8377aa23d67fd9e2753f59426e624adc"; logging-data="27784"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JySmPUetIYoMwOb7j6gRaGMOeYIsPFp8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 Cancel-Lock: sha1:Zi6muFnUollccja0Yv/Jf16rYCY= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61653 List-Id: On 3/24/21 12:00 AM, John Perry wrote: > > | if denom <= 0.0 then > | [constraint_error when > | objects__thing_typeD3 (obj.kind) > | "discriminant check failed"] > | [constraint_error when > | objects__thing_typeD3 (obj.kind) > | "discriminant check failed"] > | return (vectors__vector_dot (obj.norm, ray.start) + > | obj.offset) / (-denom); > > Am I right in thinking this is a bug? It shouldn't even check it, let alone check it twice. It's not technically an error. Both Obj.Norm and Obj.Offset depend on a discriminant, so having two checks is technically OK. But eliminating the checks completely seems like a basic optimization that one would expect at -O3. It's possible that this kind of optimization takes place later, and I guess the only way to check that would be to look at the assembler. You could perhaps create a reproducer that demonstrates the timing difference and submit it to AdaCore. -- Jeff Carter "[I]f you ask, 'Why does Ada do/have this?', the answer often makes you a better programmer." Chad R. Meiners 177