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: | 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)
Change History (3)
by , 8 years ago
Attachment: | ptr_array.zip added |
---|
by , 8 years ago
Attachment: | ptr_array2.zip added |
---|
comment:1 by , 8 years ago
Note:
See TracTickets
for help on using tickets.
The patch in ptr_array.zip is broken, please use the one in ptr_array2.zip.