Qing Zhao 1cf8d08a97 Passing TYPE_SIZE_UNIT of the element as the 6th argument to .ACCESS_WITH_SIZE (PR121000)
The size of the element of the FAM _cannot_ reliably depends on the original
TYPE of the FAM that we passed as the 6th parameter to the .ACCESS_WITH_SIZE:

     TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (gimple_call_arg (call, 5))))

when the element of the FAM has a variable length type. Since the variable
 that represents TYPE_SIZE_UNIT has no explicit usage in the original IL,
compiler transformations (such as DSE) that are applied before object_size
phase might eliminate the whole definition to the variable that represents
the TYPE_SIZE_UNIT of the element of the FAM.

In order to resolve this issue, instead of passing the original TYPE of the
FAM as the 6th argument to .ACCESS_WITH_SIZE, we should explicitly pass the
original TYPE_SIZE_UNIT of the element TYPE of the FAM as the 6th argument
to the call to  .ACCESS_WITH_SIZE.

	PR middle-end/121000

gcc/c/ChangeLog:

	* c-typeck.cc (build_access_with_size_for_counted_by): Update comments.
	Pass TYPE_SIZE_UNIT of the element as the 6th argument.

gcc/ChangeLog:

	* internal-fn.cc (expand_ACCESS_WITH_SIZE): Update comments.
	* internal-fn.def (ACCESS_WITH_SIZE): Update comments.
	* tree-object-size.cc (access_with_size_object_size): Update comments.
	Get the element_size from the 6th argument directly.

gcc/testsuite/ChangeLog:

	* gcc.dg/flex-array-counted-by-pr121000.c: New test.
2025-07-10 20:31:17 +00:00
2025-07-09 00:20:02 +00:00
2025-07-10 00:20:18 +00:00
2025-07-10 10:59:02 -04:00
2025-07-10 00:20:18 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4 GiB
Languages
C++ 31%
C 30.3%
Ada 14.9%
D 6.2%
Go 5.9%
Other 11.2%