Re: Invalid use of 'void'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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++:
https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Pointer-Arith.html#Pointer-Arith

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.
https://wiki.sei.cmu.edu/confluence/display/c/ARR36-C.+Do+not+subtract+or+compare+two+pointers+that+do+not+refer+to+the+same+array




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux