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

Paul Eggert <eggert at gnu dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eggert at gnu dot org

--- Comment #3 from Paul Eggert <eggert at gnu dot org> ---
Created attachment 44216
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44216&action=edit
Extract from Emacs source code illustrating the bug

I see this bug's symptoms when compiling Emacs with gcc (GCC) 8.1.1 20180502
(Red Hat 8.1.1-1) on x86-64. I narrowed it down to the attached source file
x.i. When I compile it with:

gcc -S -Wformat-overflow=1 -O2 x.i

I get the following diagnostic, which is a false alarm as the sprintf call
cannot overflow because the value is obviously in the range 0..0x3FFFFF.

x.i: In function ‘x_draw_glyphless_glyph_string_foreground’:
x.i:29:22: warning: ‘__builtin___sprintf_chk’ may write a terminating nul past
the end of the destination [-Wformat-overflow=]
   sprintf (buf, "%0*X", ch < 0x10000 ? 4 : 6, ch);
                      ^
x.i:9:10: note: ‘__builtin___sprintf_chk’ output between 5 and 8 bytes into a
destination of size 7
   return __builtin___sprintf_chk (s, 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __builtin_object_size (s, 1), fmt,
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __builtin_va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to