On Wed, Aug 8, 2012 at 12:09 PM, Elmar Krieger <el...@cmbi.ru.nl> wrote:
>> Not at all high. See Type-Based Alias Analysis >> <http://www.drdobbs.com/cpp/type-based-alias-analysis/184404273> >> for one reason. > > Thanks, I read the article, but didn't really see how forbidding a function > with argument void** to accept a pointer to any pointer helps with aliasing. > > If it's perfectly normal that a function with argument void* accepts any > pointer, then a function with argument void** should accept a pointer to any > pointer by analogy, without having additional aliasing problems, no? The C and C++ languages could work that way, yes. But they don't. GCC attempts to implement the standard language. Aliasing issues arise when a function has two pointers, and determine whether an assignment to *p1 might change the value at *p2. There are no aliasing issues with a void* pointer, because if p1 is void* then *p1 is invalid. That is not true for a void** pointer, so aliasing issues do arise. If p1 is void** and p2 is int**, then GCC will assume that an assignment to *p1 does not change the value at *p2, as the language standard states. It's easy to imagine that that could break a program after inlining. Ian