Opened 15 years ago

Closed 15 years ago

#1301 closed Bugs (wontfix)

copy-initialization from const-qualified object doesn't work

Reported by: Shunsuke Sogame <pstade.mb@…> Owned by: Fernando Cacciola
Milestone: Boost 1.35.0 Component: optional
Version: Boost 1.34.1 Severity: Problem
Keywords: Cc:

Description

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.

int const i = 10; boost::optional<int const &> o = i; copy-initialization BOOST_TEST(&*o == &i); failed on gcc3.4 and 4.1.

Attachments (1)

optional_init_bug.cpp (290 bytes ) - added by Shunsuke Sogame <pstade.mb@…> 15 years ago.
a failed test

Download all attachments as: .zip

Change History (4)

by Shunsuke Sogame <pstade.mb@…>, 15 years ago

Attachment: optional_init_bug.cpp added

a failed test

comment:1 by Fernando Cacciola, 15 years ago

Status: newassigned

I think it's a gcc bug. In any case I added the missing test case to see how other compilers handle it.

in reply to:  1 ; comment:2 by Shunsuke Sogame <pstade.mb@…>, 15 years ago

Replying to fcacciola:

I think it's a gcc bug. In any case I added the missing test case to see how other compilers handle it.

Thanks for adding a test into optional_test_ref.cpp. BTW, optional<int const&> orci2 = ci ; is a typo of optional<int const&> orci2(ci) ; ?

in reply to:  2 comment:3 by Fernando Cacciola, 15 years ago

Resolution: wontfix
Status: assignedclosed

Replying to Shunsuke Sogame <pstade.mb@gmail.com>:

Replying to fcacciola:

I think it's a gcc bug. In any case I added the missing test case to see how other compilers handle it.

Thanks for adding a test into optional_test_ref.cpp.

:) BTW, I noticed that you have updated a test case only when I replied to the ticket, after I already added my own test case.

BTW, optional<int const&> orci2 = ci ; is a typo of optional<int const&> orci2(ci) ; ?

Oops, of course.

BTW. I confimed this is a gcc bug as this simple program shows it:

struct crw {

crw ( int const& _cref ) : cref(_cref) {}

int const& cref ;

} ;

int main( int, char* [] ) {

int const ci = 0 ; crw copy_init(ci); assert( &copy_init.cref == &ci ) ;

crw direct_init = ci ; assert( &direct_init.cref == &ci ) ; This one fails here

}

I'm marking the new failures as expected.

Note: See TracTickets for help on using tickets.