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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |tree-optimization

--- Comment #7 from Sam James <sjames at gcc dot gnu.org> ---
At -O2, 4.8.1 fails and 4.7.4 works for:
```
long sized_strscpy_size;
struct audit_context *audit_context();
struct lsm_prop {
} security_task_getlsmprop_obj();

void __write_overflow() __attribute__((
    __error__("detected write beyond size of object (1st parameter)")));

struct audit_context {
  int target_pid;
  struct lsm_prop target_ref;
  char target_comm[];
} __audit_ptrace() {
  struct audit_context *context = audit_context();
  security_task_getlsmprop_obj(&context->target_ref);
  unsigned long p_size = __builtin_object_size(context->target_comm, 1);
  if (p_size < sized_strscpy_size)
    __write_overflow();
}
```

Clang accepts it. s/_dynamic/ to test with older GCC.

Reply via email to