There's a patch to add __builtin_dynamic_object_size to clang: https://reviews.llvm.org/D56760
It was suggested that this could be done via a new flag bit for __builtin_object_size, but only if GCC would support that too (otherwise it would be done as a separate builtin). Is there any interest in adding that as an option to __builtin_object_size? I know Jakub is concerned about arbitrarily complex expressions, when __builtin_object_size is supposed to always be efficient and always evaluate at compile time (which would imply the dynamic behaviour should be a separate builtin, if it exists at all).