title: Suppress unused variable warning in C++ => Compiler bug or code bug?
body: <p>Presently, I am using the following function template to suppress unused variable warnings:</p>
  
  <pre><code>template&lt;typename T&gt;
  void
  unused(T const &amp;) {
    /* Do nothing. */
  }
  </code></pre>
  
  <p>However, when porting to cygwin from Linux, I am now getting compiler errors on g++ 3.4.4 (On linux I am 3.4.6, so maybe this is a bug fix?):</p>
  
  <pre><code>Write.cpp: In member function `void* Write::initReadWrite()':
  Write.cpp:516: error: invalid initialization of reference of type 'const volatile bool&amp;' from expression of type 'volatile bool'
  ../../src/common/Assert.h:27: error: in passing argument 1 of `void unused(const T&amp;) [with T = volatile bool]'
  make[1]: *** [ARCH.cygwin/release/Write.o] Error 1
  </code></pre>
  
  <p>The argument to unused is a member variable declared as:</p>
  
  <pre><code>  volatile bool readWriteActivated;
  </code></pre>
  
  <p>Is this a compiler bug or a bug in my code?</p>
  
  <p>Here is the minimal test case:</p>
  
  <pre><code>template&lt;typename T&gt;
  void unused(T const &amp;) { }
  
  int main() {
    volatile bool x = false;
    unused(!x); // type of "!x" is bool
  }
  </code></pre>