https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123500

--- Comment #2 from qinzhao at gcc dot gnu.org ---
this is a bug that C FE does not handle the IR for counted_by of pointers
correctly.

for the following source code:

(uintptr_t)b->ptr;

when b->ptr has an counted_by annotation, the IR for this pointer reference is
changed to a call to .ACCESS_WITH_SIZE as:

(uintptr_t).ACCESS_WITH_SIZE (b->ptr, &b->len, 0B, 1);

As a result, the following code in the routine "build_c_cast" is invoked:

 7455       if (TREE_CODE (value) == CALL_EXPR
 7456           && TREE_CODE (type) != TREE_CODE (otype))
 7457         warning_at (loc, OPT_Wbad_function_cast,
 7458                     "cast from function call of type %qT "
 7459                     "to non-matching type %qT", otype, type);
 7460 

It's obviously that C FE should exclude the call to .ACCESS_WITH_SIZE from
issuing such warning.

Reply via email to