    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: The Wall</title>
        <link>https://members.accu.org/index.php/articles/1056</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">Letters to the Editor + CVu Journal Vol 12, #5 - Sep 2000</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c184/">Journal Columns</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c186/">LettersEditor</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c124/">125</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c186-124/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c186+124/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;The Wall</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 08 September 2000 13:15:39 +01:00 or Fri, 08 September 2000 13:15:39 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a>Undefined?</h2>
</div>
<p>Dear Francis,</p>
<p>One Friday afternoon, I was playing around with writing useful
little utilities and ended up writing the following 'optimised'
code; a test in operator precedence maybe :-)</p>
<pre class="programlisting">
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
static void p(int v, int b) {
  do {
    int c = (b-,8);
    do 
      putchar(v &amp; 1 &lt;&lt;b * 8+ -c ? '1' : '0')
        , b|c &amp;&amp; c%4 != 0||putchar(' ');
    while (c);
  }
  while (b);
}

int main(int c, char** a) {
  while (-c) {
    int v = strtol(* ++a, 0, 0), 
      b = 1&lt;&lt;(v &gt;&gt; 16 != 0)+(v&gt;&gt;8 != 0);
    printf(&quot;dec=%d hex=%#0*x bin=&quot;,v,2+2*b,v)
      , p (v, b), putchar('\n');
  }
  return c;
}
</pre>
<p>While I include this for your amusement, in trying to optimise
it further, I did stumble upon writing:</p>
<pre class="programlisting">
int i = i ^ i;
</pre>
<p>My question would be, out of purely satanic interest is does
this produce undefined behaviour or not? Since I'm not well versed
in the standard, I thought I'd ask the expert :-)</p>
<p class="c3"><span class="remark">Do your employers know you have
this addiction? When the compiler has seen the declaration part of
the statement, 'i' is in scope. As the evaluation of the
initialisation expression requires that i be read before it has
been initialised, you have undefined behaviour. While most
implementations use all the bit patterns to represent values, some
do not have what are called trap values. The result of the contents
of i being initially a trap value would result in behaviour outside
the scope of the Standards for both C and C++.</span></p>
<p class="c3"><span class="remark">Note that there is no
requirement that the compiler can analyse your code to the extent
of evaluating the expression, so it is no use arguing that the
compiler can know that the expression necessarily evaluates to
0.</span></p>
<p class="c3"><span class="remark">I hope that helps.</span></p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
