https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124969
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:df63f12b50c9a0aa39c028b49555e4c46c2b6c55 commit r16-8795-gdf63f12b50c9a0aa39c028b49555e4c46c2b6c55 Author: Jakub Jelinek <[email protected]> Date: Wed Apr 22 07:52:25 2026 +0200 c-family: Fix ICE with counted_by attribute [PR124969] The following valid testcase ICEs, because we try to use TREE_CODE (NULL_TREE). We document that counted_by is supported on pointers to void and that it behaves like the GNU pointer to void arithmetics extension in that case. build_access_with_size_for_counted_by already uses 1 in that case as element_size. The following patch fixes it, plus for error recovery punts if it is a pointer to incomplete type other than void (pointer arithmetics on such type will be diagnosed as error later on). 2026-04-22 Jakub Jelinek <[email protected]> PR sanitizer/124969 * c-ubsan.cc (get_index_from_pointer_addr_expr): For VOID_TYPE_P (pointee_type) use size_one_node instead of TYPE_SIZE_UNIT (pointee_type) as pointee_size. Punt for !COMPLETE_OR_VOID_TYPE_P (pointee_type). Formatting fix. Use CONVERT_EXPR_P (x) instead of CONVERT_EXPR_CODE_P (TREE_CODE (x)). * gcc.dg/ubsan/pr124969-1.c: New test. Reviewed-by: Marek Polacek <[email protected]>
