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,8982dc345b43855,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!irazu.switch.ch!kanaga.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Uninitialized variable and the effects they have Date: Thu, 24 Nov 2005 10:36:34 +0100 Organization: CERN - European Laboratory for Particle Physics Message-ID: NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1132824993 15167 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Red Hat/1.7.12-1.1.3.2.SL3 X-Accept-Language: en-us, en Xref: g2news1.google.com comp.lang.ada:6581 Date: 2005-11-24T10:36:34+01:00 List-Id: Hello, Consider: procedure Hello is I : Integer; -- uninitialized begin case I is when 5 => Put("I got five!"); when others => Put("I got something else"); end case; -- continue with further statements -- ... end Hello; Is the behaviour of this program well-defined? I mean - I consider it to be well defined if it's guaranteed that exactly one of the branches is chosen and later statements are executed without any restrictions. What bothers me is the fact that AARM seems to guarantee this (5.4/10.b), but at the same time this would mean that the implementation may need to take some special steps to make it happen. On the platform where the integer type is allowed to have trap values in its representation (ie. there are possible bit patterns that are not considered to be valid numbers, which may cause the CPU to trigger bus error events or alike), the Ada implementation would need to somehow take care of them and route them to the "others" category. On the other hand, catching CPU critical errors might not be possible at all, or might in fact hide true hardware errors. Granted, the implementation is not obliged to use the underlying hardware in the straightforward way. What is really intended here? This can be also restated another way: I : Integer; -- uninitialized J : Integer := I + 2; What can be said about this code, with similar issues in mind? Note that in C++ using (let's say reading) the uninitialized variable causes undefined behaviour, so both examples above could cause whatever effect on more exotic platform (including hardware lockup - why not?). If Ada makes it well-defined, I would like to know how it does it. Please do not hesitate to point me to relevant AARM chapters. Regards, -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/