title: Is there a workaround for this C4702 link-time warning?
body: <p>I'm using boost::variant and am having trouble compiling in release mode. I am working in VC2010 with warning level 4 and warnings as errors. The code below compiles fine in debug mode, but in release mode I get a bunch of "Unreachable code" C4702 warnings emitted at link time (presumably I'm getting compiler warnings here because there is link time code generation when optimisations are enabled.)</p>
  
  <p>Has anybody successfully disabled these warnings in this situation? I would prefer to keep the high warning level and warnings as errors if possible.</p>
  
  <pre><code>#pragma warning( disable:4702 )
  </code></pre>
  
  <p>... doesn't seem to work here. Here is some sample code:</p>
  
  <pre><code>#include &lt;boost/variant.hpp&gt;
  
  struct null{};
  typedef boost::variant&lt; null, double &gt; variant_t;
  
  class addition_visitor
  : public boost::static_visitor&lt; variant_t &gt;
  {
  public:
      template&lt; typename T, typename U &gt;
      variant_t operator()( const T&amp;, const U&amp; ) const
      { 
          throw( "Bad types" );
      }
  
      variant_t operator()( const double&amp; left, const double&amp; right ) const
      {
          return variant_t( left * right );
      }
  };
  
  int main(int /*argc*/, char** /*argv*/)
  {
      variant_t a( 3.0 ), b( 2.0 );
      variant_t c = boost::apply_visitor( addition_visitor(), a, b );
      return 0;
  }
  </code></pre>
  
  <p>The warning is triggered by the templated operator(), which I'm using to catch attempts to apply the visitor to bad variant types.</p>