[Bug c/80806] gcc does not warn if local array is memset only

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 18 20:26:00 GMT 2017


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The challenge is that the DECL_READ_P flag is set indiscriminately by the front
end (in convert_lvalue_to_rvalue called from c_parser_expr_list while parsing
the argument list in the function call expression) in response to seeing the
array being passed to a function as an argument.  There's no logic that would
take into account the properties of the function is being called.  In general,
GCC also has no notion of "out" only arguments (such as memset's first), or
"in" only (such as memcpy's second).  It may be a useful concept to introduce
in the form of an attribute.  With such an attribute, this issue could then be
detected in for any function whose arguments were decorated with it.


More information about the Gcc-bugs mailing list