This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/86199] warn on calls to strlen with same argument as in strnlen


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

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Ditto for strdup vs strndup, although there it might be worth considering
diagnosing only calls where the strndup bound is equal the size of the source
array, as in:

char a[4], *p, *q;

void f (void)
{
  p = __builtin_strdup (a);              // possibly unsafe? if not then...
  // ...
  q = __builtin_strndup (a, sizeof a);   // this could be replaced by strdup()
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]