title: Why is the address of an array element sometimes mistaken for a declaration?
body: <p>I have some user defined iterators, and every now and then I get a strange error that is easy to work around, but I don't understand why I'm getting it:</p>
  
  <pre><code>uint8_t bytes[pitch*height];
  
  array_iterator::col_iterator a( &amp;bytes[0] );
  
  array_iterator::row_iterator base_iter_begin(
    array_iterator::col_iterator( &amp;bytes[0] ), width, pitch );
  
  array_iterator::row_iterator base_iter_end(
    array_iterator::col_iterator( &amp;bytes[pitch*height] ), width, pitch
    );
  </code></pre>
  
  <p>I have a class called array_iterator with embedded typedefs row_iterator and col_iterator.  The row_iterator constructor takes a col_iterator as its first argument.   The first and last statement work just fine.  The middle statement fails to compile with the following error:</p>
  
  <pre><code>test-2d-iterators.cc:780: error: declaration of 'bytes' as array of references
  </code></pre>
  
  <p>Writing &amp;( bytes[0] ) doesn't solve the problem (not surprisingly, since [] has higher precedence than &amp;).  Of course, I can just substitute "a" for the explicit col_iterator constructor call, but why do I have to?  And if there is a problem, why does the col_iterator constructor in the last line compile?</p>
  
  <p>Thanks.</p>