Boost C++ Libraries: Ticket #9239: Implicit type conversion without warning, although Wconversion used https://svn.boost.org/trac10/ticket/9239 <p> When defining a variable with automatic type recognition, </p> <pre class="wiki">auto inv_time = 1/si::second; </pre><p> this instruction </p> <pre class="wiki">inv_time = 0.4/si::second; </pre><p> does not generate a warning (using -Wconversion), while </p> <pre class="wiki">auto p = 3; p = 1.0/2.0; </pre><p> generates a warning, as it should. Is there any reason for the different behavior in both cases? It should be mentioned that this is not contingent to "auto", for </p> <pre class="wiki">quantity&lt;si::time,int&gt; time = 1/(1/si::second); time = 0.4*si::second; </pre><p> compiles without warning, too (and time = 0 s in the end). I thought implicit typecasts with possible loss of precision were forbidden or would at least trigger a warning. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9239 Trac 1.4.3 Steven Watanabe Tue, 11 Mar 2014 00:45:23 GMT <link>https://svn.boost.org/trac10/ticket/9239#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9239#comment:1</guid> <description> <p> It's not really possible to emulate the behavior of built in types in this regard. If it did generate a warning it would be impossible to suppress with a cast. </p> </description> <category>Ticket</category> </item> </channel> </rss>