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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic, lto
           Priority|P3                          |P2
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2016-07-18
          Component|lto                         |middle-end
   Target Milestone|---                         |6.2
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
With LTO we expand from

  <bb 2>:
  s = "12345678";
  __builtin___memcpy_chk (&d, &s, 9, 4);
  __builtin_puts (&d);

and we _do_ enter expand_builtin_memory_chk warning_at code.  But the location
is completely bogus:

(gdb) p richloc
$11 = {static MAX_RANGES = 3, static MAX_FIXIT_HINTS = 2, m_num_ranges = 1, 
  m_ranges = {{m_loc = 2147483649, m_show_caret_p = true}, {m_loc = 32767, 
      m_show_caret_p = 144}, {m_loc = 32767, m_show_caret_p = 23}}, 
  m_column_override = 0, m_have_expanded_location = false, 
  m_expanded_location = {
    file = 0xc0ffffcc90 <error: Cannot access memory at address 0xc0ffffcc90>, 
    line = -12960, column = 32767, data = 0x7fffffffcd00, sysp = 96}, 
  m_num_fixit_hints = 0, m_fixit_hints = {0x7fffffffccc0, 0x7fffffffcd00}}

in particular 'sysp' is not zero.  Thus:

> gcc-6 t.c -O2 -D_FORTIFY_SOURCE=2 -flto -Wsystem-headers
In function ‘strcpy’,
    inlined from ‘main’ at t.c:5:5:
/usr/include/bits/string3.h:104:10: warning: call to __builtin___memcpy_chk
will always overflow destination buffer
   return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
          ^

and viola, it works.  This probably means tree_nonartificial_location doesn't
work correctly (anymore).  I will have a closer look.

Reply via email to