Invalid use of 'void'

Niklas Gürtler
Mon May 18 15:03:56 GMT 2020

On 5/18/20 12:30 PM, Игорь Горлов wrote:
> This program is not compatible with the C++17 standard. However, we can compile it with -std=gnu++17 (C++17 with GNU extensions), because one of that extensions permits calculations on void pointers.

It appears the extension is only for C, not for C++:

Also, the C and C++ standards forbid subtracting pointers that do not
point into the same array, so subtracting the results of two distinct
'malloc' calls is undefined behaviour.

See e.g.

More information about the Gcc-help mailing list