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,308a261188818cce X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!g12g2000prg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Pointers explained? Date: Mon, 30 Jul 2007 15:36:02 -0700 Organization: http://groups.google.com Message-ID: <1185834962.845369.84390@g12g2000prg.googlegroups.com> References: <1185817996.143086.317990@g12g2000prg.googlegroups.com> <1185818189.689914.159900@x40g2000prg.googlegroups.com> <1185824195.711745.136860@i13g2000prf.googlegroups.com> <1185830614.681672.154960@g4g2000hsf.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1185834964 27389 127.0.0.1 (30 Jul 2007 22:36:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 30 Jul 2007 22:36:04 +0000 (UTC) In-Reply-To: <1185830614.681672.154960@g4g2000hsf.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g12g2000prg.googlegroups.com; posting-host=66.126.103.122; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1281 Date: 2007-07-30T15:36:02-07:00 List-Id: On Jul 30, 2:23 pm, Maciej Sobczak wrote: > On 30 Lip, 21:36, Adam Beneschan wrote: > > > C++ will of > > course let you do that > > C++ will of course let you do that, but this statement itself is > meaningless, because languages are never used directly. In real life > you might want to use a *compiler* to compile the C++ code and recent > versions of g++ produce a nice warning message when you try to return > an address of a local variable (even without any additional options). > I guess other C++ compilers are smart enough to do the same, so it's > not that bad. Please refer to the first thing I said in my response. I guess you proved it correct. :) I basically use C++ when I'm absolutely forced to and never at any other time, so I'll take your word for it. > On the other hand it is true that the whole scenario can be made more > complex up to the point where the compiler will not catch the problem, > but will have to accept it, so it's not perfect either. > > Note that Ada programmers also have 'Unrestricted_Access (GNAT) and > 'Unchecked_Access to cheat around the rules. Yes, but Ada programmers are aware of the danger and understand why the rules are there; and they won't use 'Unchecked_Access unless it's absolutely necessary and they know there won't be any dangling pointer problems. Note that "Ada programmer" is not a synonym for "programmer who uses Ada" here. I'm sure there are plenty of programmers who use Ada but think like C/C++ programmers. Those programmers would see the error message that says 'Access is illegal because of the accessibility rules, and figure they can solve the problem simply by changing it to 'Unchecked_Access". Unfortunately, I've seen that sort of Ada code--- quite frustrating. -- Adam