Boost C++ Libraries: Ticket #10149: boost::optional<T> can be constructed from a typed in place factory of the wrong type https://svn.boost.org/trac10/ticket/10149 <p> For example: </p> <p> boost::optional&lt;char&gt; oa = boost::in_place&lt;double&gt;(0); <em> type-checks but results in runtime undefined behavior, placement new of double in a buffer of size char. </em></p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10149 Trac 1.4.3 anonymous Tue, 15 Mar 2016 12:24:35 GMT <link>https://svn.boost.org/trac10/ticket/10149#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10149#comment:1</guid> <description> <p> Can you provide a short but complete example that demonstrates the problem? </p> <p> I can see that the following code does not even compile on GCC and Clang (which is desirable). </p> <pre class="wiki">#include &lt;boost/utility/in_place_factory.hpp&gt; #include &lt;boost/optional.hpp&gt; int main() { boost::optional&lt;char&gt; oa = boost::in_place&lt;double&gt;(0); } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 15 Mar 2016 12:29:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10149#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10149#comment:2</guid> <description> <p> What compiler are you using? </p> </description> <category>Ticket</category> </item> </channel> </rss>