Blender Git Commit Log

Git Commits -> Revision 4463087

Revision 4463087 by Jacques Lucke (master)
December 16, 2020, 15:00 (GMT)
BLI: remove implicit casts between some span types

Casting pointers from one type to another does change the
value of the pointer in some cases. Therefore, casting a span
that contains pointers of one type to a span that contains
pointers of another type, is not generally safe. In practice, this
issue mainly comes up when dealing with classes that have a
vtable.

There are some special cases that are still allowed. For example,
adding const to the pointer does not change the address.
Also, casting to a void pointer is fine.

In cases where implicit conversion is disabled, but one is sure
that the cast is valid, an explicit call of `span.cast<NewType>()`
can be used.

Commit Details:

Full Hash: 4463087223983c40a6d67beab0513fba7cdb7538
Parent Commit: 684c771
Lines Changed: +37, -6

5 Modified Paths:

/source/blender/blenlib/BLI_array.hh (+2, -2) (Diff)
/source/blender/blenlib/BLI_memory_utils.hh (+19, -0) (Diff)
/source/blender/blenlib/BLI_span.hh (+3, -2) (Diff)
/source/blender/blenlib/BLI_vector.hh (+2, -2) (Diff)
/source/blender/blenlib/tests/BLI_memory_utils_test.cc (+11, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021