Boost C++ Libraries: Ticket #1301: copy-initialization from const-qualified object doesn't work https://svn.boost.org/trac10/ticket/1301 <p> A copy-initialization from const-qualified object doesn't work on gcc-3.4 and gcc-4.1, whereas msvc-7.1 and msvc-8.0 work. </p> <blockquote> <p> int const i = 10; boost::optional&lt;int const &amp;&gt; o = i; <em> copy-initialization BOOST_TEST(&amp;*o == &amp;i); </em> failed on gcc3.4 and 4.1. </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1301 Trac 1.4.3 Shunsuke Sogame <pstade.mb@…> Fri, 05 Oct 2007 16:58:02 GMT attachment set https://svn.boost.org/trac10/ticket/1301 https://svn.boost.org/trac10/ticket/1301 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">optional_init_bug.cpp</span> </li> </ul> <p> a failed test </p> Ticket Fernando Cacciola Fri, 02 Nov 2007 23:45:56 GMT status changed https://svn.boost.org/trac10/ticket/1301#comment:1 https://svn.boost.org/trac10/ticket/1301#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> I think it's a gcc bug. In any case I added the missing test case to see how other compilers handle it. </p> Ticket Shunsuke Sogame <pstade.mb@…> Sat, 03 Nov 2007 08:29:34 GMT <link>https://svn.boost.org/trac10/ticket/1301#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1301#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/1301#comment:1" title="Comment 1">fcacciola</a>: </p> <blockquote class="citation"> <p> I think it's a gcc bug. In any case I added the missing test case to see how other compilers handle it. </p> </blockquote> <p> Thanks for adding a test into optional_test_ref.cpp. BTW, <code>optional&lt;int const&amp;&gt; orci2 = ci ;</code> is a typo of <code>optional&lt;int const&amp;&gt; orci2(ci) ;</code> ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Fernando Cacciola</dc:creator> <pubDate>Tue, 06 Nov 2007 22:07:48 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1301#comment:3 https://svn.boost.org/trac10/ticket/1301#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/1301#comment:2" title="Comment 2">Shunsuke Sogame &lt;pstade.mb@gmail.com&gt;</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/1301#comment:1" title="Comment 1">fcacciola</a>: </p> <blockquote class="citation"> <p> I think it's a gcc bug. In any case I added the missing test case to see how other compilers handle it. </p> </blockquote> <p> Thanks for adding a test into optional_test_ref.cpp. </p> </blockquote> <p> :) BTW, I noticed that you have updated a test case only when I replied to the ticket, <strong>after</strong> I already added my own test case. </p> <blockquote class="citation"> <p> BTW, <code>optional&lt;int const&amp;&gt; orci2 = ci ;</code> is a typo of <code>optional&lt;int const&amp;&gt; orci2(ci) ;</code> ? </p> </blockquote> <p> Oops, of course. </p> <p> BTW. I confimed this is a gcc bug as this simple program shows it: </p> <p> struct crw { </p> <blockquote> <p> crw ( int const&amp; _cref ) : cref(_cref) {} </p> </blockquote> <p> </p> <blockquote> <p> int const&amp; cref ; </p> </blockquote> <p> } ; </p> <p> int main( int, char* [] ) { </p> <blockquote> <p> int const ci = 0 ; crw copy_init(ci); assert( &amp;copy_init.cref == &amp;ci ) ; </p> </blockquote> <p> </p> <blockquote> <p> crw direct_init = ci ; assert( &amp;direct_init.cref == &amp;ci ) ; <em> This one fails here </em></p> </blockquote> <p> } </p> <p> I'm marking the new failures as expected. </p> Ticket