https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70090
--- Comment #2 from Daniel Micay <danielmicay at gmail dot com> --- This has now been implemented in Clang as __builtin_dynamic_object_size. There's a thread on the GCC mailing list about it at https://www.mail-archive.com/gcc@gcc.gnu.org/msg87230.html.