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,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Sun, 06 Feb 2011 19:18:23 +0100 Organization: Tidorum Ltd Message-ID: <8r86vgFc3uU1@mid.individual.net> References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <31c357bd-c8dc-4583-a454-86d9c579e5f4@m13g2000yqb.googlegroups.com> <05a3673e-fb97-449c-94ed-1139eb085c32@x1g2000yqb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Wgq/JqpGgvUe4c34wuwkvwmzV3h0qBaBslVigorN4uy7AfWJeS Cancel-Lock: sha1:GFOEUnc3sS5cn0e1NbWlWQrajvU= User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:17869 Date: 2011-02-06T19:18:23+01:00 List-Id: Simon Clubley wrote: > On 2011-02-04, Ludovic Brenta wrote: >> Ludovic Brenta wrote: >>> Syntax Issues wrote on comp.lang.ada: >>>> ... >>>> unsigned int print(char *message, unsigned int line) >>>> { >>>> char *vidmem = (char *) 0xb8000; >>>> unsigned int i= 0; >>>> >>>> i=(line*80*2); >>>> >>>> while(*message!=0) // 24h >> Did I mention that *every* time I look at C code I see a bug? >> Sometimes, looking twice at the same code reveals two bugs! Here you >> do not check that message != NULL; the condition should be: >> >> while (message && *message != 0) >> > > That still isn't good enough unless you can guarantee that the compiler > generated code will not evaluate the second condition if the first condition > is false. That is guaranteed in C. The C "&&" operator is short-circuiting and corresponds to the Ada "and then". The C99 standard says "If the first operand compares equal to 0, the second operand is not evaluated." -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .