title: Finding off_t size
body: <p>We have been using a <a href="http://code.google.com/p/openjpeg/issues/detail?id=316" rel="nofollow">trick</a> copied from the autotools to determine off_t size and whether or not we needed to define _FILE_OFFSET_BITS=64. However this trick seems to fails in recent gcc (>= 4.6). Here is the code:</p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  
  int main(int argc, char **argv)
  {
    /* Cause a compile-time error if off_t is smaller than 64 bits */
  #define LARGE_OFF_T (((off_t) 1 &lt;&lt; 62) - 1 + ((off_t) 1 &lt;&lt; 62))
    int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 &amp;&amp; LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ];  
    return 0;
  }
  </code></pre>
  
  <p>From my debian/amd64 &amp; debian/ppc installation here is what I get (instead of compile time error):</p>
  
  <pre><code>$ gcc-4.6 -O0 -m32 -o valid.o valid.c 
  valid.c: In function ‘main’:
  valid.c:7:3: warning: left shift count &gt;= width of type [enabled by default]
  valid.c:7:3: warning: left shift count &gt;= width of type [enabled by default]
  valid.c:7:3: warning: left shift count &gt;= width of type [enabled by default]
  valid.c:7:3: warning: left shift count &gt;= width of type [enabled by default]
  </code></pre>
  
  <p>So my question, can I simply replaced this code with the following one:</p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  
  int main(int argc, char **argv)
  {
    /* Cause a compile-time error if off_t is smaller than 64 bits */
    int off_t_is_large[ sizeof(off_t) &gt;= 8 ? 1 : -1 ];  
    return 0;
  }
  </code></pre>
  
  <p>(extra) question: is this a regression in gcc, or was the initial code just relying on a broken feature ?</p>