https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104970
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Siddhesh Poyarekar <siddh...@gcc.gnu.org>: https://gcc.gnu.org/g:c1d233e3334df07cfb4f732ace4d93d3cbc28bca commit r12-7794-gc1d233e3334df07cfb4f732ace4d93d3cbc28bca Author: Siddhesh Poyarekar <siddh...@gotplt.org> Date: Wed Mar 23 23:09:02 2022 +0530 tree-optimization/104970: Limit size computation for access attribute Limit object size computation only to the simple case where access attribute has been explicitly specified. The object passed to __builtin_dynamic_object_size could either be a pointer or a VLA whose size has been described using access attribute. Further, return a valid size only if the object is a void * pointer or points to (or is a VLA of) a type that has a constant size. gcc/ChangeLog: PR tree-optimization/104970 * tree-object-size.cc (parm_object_size): Restrict size computation scenarios to explicit access attributes. gcc/testsuite/ChangeLog: PR tree-optimization/104970 * gcc.dg/builtin-dynamic-object-size-0.c (test_parmsz_simple2, test_parmsz_simple3, test_parmsz_extern, test_parmsz_internal, test_parmsz_internal2, test_parmsz_internal3): New tests. (main): Use them. Signed-off-by: Siddhesh Poyarekar <siddh...@gotplt.org>