Opened 8 years ago

Last modified 8 years ago

#10834 new Bugs

ptr_array cannot be used with boost::nullable<T> as type parameter

Reported by: florian.schmid1978@… Owned by: Thorsten Ottosen
Milestone: To Be Determined Component: ptr_container
Version: Boost 1.57.0 Severity: Problem
Keywords: Cc:

Description

The copy constructor of ptr_array uses operator[] to access the elements of the ptr_array to copy.
Problem one: It is not save to call ptr_array[i] if element i is null.
Problem two: Operator[] returns a reference to remove_nullable<T>::type. The address of this object is then casted to const T*, which fails with compilation error C2664 if T=nullable<X>, because X* cannot be casted to nullable<X>*.

Reproduction: compile attached test.cpp
Possible fix: see attached patch

Regards, Florian

Attachments (2)

ptr_array.zip (657 bytes ) - added by florian.schmid1978@… 8 years ago.
ptr_array2.zip (660 bytes ) - added by florian.schmid1978@… 8 years ago.

Download all attachments as: .zip

Change History (3)

by florian.schmid1978@…, 8 years ago

Attachment: ptr_array.zip added

by florian.schmid1978@…, 8 years ago

Attachment: ptr_array2.zip added

comment:1 by florian.schmid1978@…, 8 years ago

The patch in ptr_array.zip is broken, please use the one in ptr_array2.zip.

Note: See TracTickets for help on using tickets.