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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually I've misremembered what we've added 12 years ago.
glibc has:
int
___vsnprintf_chk (char *s, size_t maxlen, int flags, size_t slen,
                  const char *format, va_list args)
{
  /* XXX Maybe for less strict version do not fail immediately.
     Though, maxlen is supposed to be the size of buffer pointed
     to by s, so a conforming program can't pass such maxlen
     to *snprintf.  */
  if (__glibc_unlikely (slen < maxlen))
    __chk_fail ();
and so it is considered a fatal error if slen < maxlen and thus the
error emitted by maybe_emit_chk_warning is the right one and at the right spot
(during expansion).  That warning tells that whenever you execute that
statement your program will fail.  That is only the matter of the two arguments
to the __vsnprintf_chk call, doesn't depend on anything else, so hiding such a
warning in an unrelated pass is just wrong.  So, please, remove the duplicate
warning from your pass where it doesn't belong.

As for the test changes you've just posted, as has been said earlier, just
convert that test to use relative warning/error numbers and you won't have to
adjust it all the time again.  See
http://gcc.gnu.org/ml/gcc-patches/2016-09/msg01617.html for details.

Reply via email to