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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,25b9eb5c3a89bced X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!i39g2000cwa.googlegroups.com!not-for-mail From: "Martin Krischik" Newsgroups: comp.lang.ada Subject: Re: where exactly c++,c fail and Ada gets thru' Date: 28 Apr 2006 00:00:23 -0700 Organization: http://groups.google.com Message-ID: <1146207623.635562.289570@i39g2000cwa.googlegroups.com> References: <1145852356.559455.222600@i39g2000cwa.googlegroups.com> <1145855124.720029.35280@t31g2000cwb.googlegroups.com> <1235818.stAph9vF03@linux1.krischik.com> NNTP-Posting-Host: 138.189.120.37 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1146207630 26841 127.0.0.1 (28 Apr 2006 07:00:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 28 Apr 2006 07:00:30 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i39g2000cwa.googlegroups.com; posting-host=138.189.120.37; posting-account=2-0LkQwAAAAQMhPSoYwlMiUmi-6lYh44 Xref: g2news2.google.com comp.lang.ada:3975 Date: 2006-04-28T00:00:23-07:00 List-Id: Maciej Sobczak wrote: > Martin Krischik wrote: > > > Now say we have a suitable C++ range template: > > > > typedef range Y_Type; > > typedef range X_Type; > > > > Y_Type F (X_Type X) > > { > > return X + 3; > > } > > > > Y_Type G (X_Type X) > > { > > return X + 7; > > } > > > > Now anyone up to the challenge to define: > > > > template > > range::operator = (Base_Type right) > > > > template > > range::operator + (Base_Type right) > > > > template > > range::range (Base_Type right) > > > > in such a way that it works like Ada - inclusive the *realistic* change that > > the compiler will optimize away the range check in F (). > > The C++ standard does not define to what extent the compilers are > allowed to optimize the resulting code. This is the quality of > implementation issue and an area of competition between compiler > vendors. Without any further checks I can claim that it is possible for > the compiler to optimize it the way you want. > > And without any further checks I take the risk to claim that the Ada > standard does not require any conforming compiler to optimize range > checks away as you described (or please throw some references) - > similarly, this is the QoI issue. > > So - what was your point? The point is - of corse - it that the semantic tree of the Ada compiler contains the information that X will be in the range of (1 .. 5) and then the optimizer can easily calculate that (1 .. 5) + 3 < 10 and then optimize away the check. The sematinc tree of the C++ will contain the information that X is in the range of (-2*32 .. +2*32-1) and that is a pretty useless information to the optimizer. Martin