Michael Stefaniuc wrote:
Ivan Gyurdiev wrote:
Type: Cleanup
Why: The const qualifier is unnecessarily restrictive. I intend to allocate and free such data on the heap in a future patch. Instead, const should be primarily used on function parameters.
Question: do you realy have to use void pointers?
Yes.
Void pointers are compatible with every pointer type and thus will disable the type checking of the compiler.
This is intentional - it's a form of polymorphism. The data stored can be of many different types. Each test knows what type of data it is using.
Also you do not need to to cast a rvalue to void * if the type of the lvalue is void *.
Yes, you do...the type of the lvalue is void*, while the type of the rvalue is const void*. Not casting produces a warning (correctly). Casting replaces the compile-time guarantee that the value will be kept constant by runtime contract [ because both const and non-const rvalue will be used in the future ].