Opened 15 years ago
Closed 15 years ago
#1301 closed Bugs (wontfix)
copy-initialization from const-qualified object doesn't work
Reported by: | 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)
Change History (4)
by , 15 years ago
Attachment: | optional_init_bug.cpp added |
---|
follow-up: 2 comment:1 by , 15 years ago
Status: | new → assigned |
---|
I think it's a gcc bug. In any case I added the missing test case to see how other compilers handle it.
follow-up: 3 comment:2 by , 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) ;
?
comment:3 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
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 ofoptional<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( ©_init.cref == &ci ) ;
crw direct_init = ci ; assert( &direct_init.cref == &ci ) ; This one fails here
}
I'm marking the new failures as expected.
a failed test