Project

General

Profile

Bug #14856

Clang removes dead code....

Added by Willem Jan Withagen over 3 years ago. Updated over 3 years ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
-
Target version:
-
Start date:
02/24/2016
Due date:
% Done:

0%

Source:
Community (dev)
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:

Description

log/Log.cc:193:5: warning: indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference]
*(int *)(0) = 0xdead;
^~~~~~~~~

Code is:
if (m_inject_segv)
*(int *)(0) = 0xdead;

So this code is definitely not going to trap when running on FreeBSD or Clang.

Code is also very unclear on why we would like to trap this way

Associated revisions

Revision c05300b1 (diff)
Added by Kefu Chai over 3 years ago

log: segv in a portable way

this piece of code creates a SEGV from logging code to verify a
bug fix at e3fe18a.

clang will delete the null-referencing code. so we need to either
- pass Wnonull-dereference to $(CC)
or use __builtin_trap() offered by GCC/clang
- or use `volatile`
seems volatile is easier and probably more portable.

Fixes: #14856
Signed-off-by: Kefu Chai <>

History

#1 Updated by Kefu Chai over 3 years ago

  • Status changed from New to Need Review
  • Assignee set to Kefu Chai
  • Priority changed from Normal to Low
  • Source changed from other to Community (dev)

#2 Updated by Nathan Cutler over 3 years ago

  • Status changed from Need Review to Resolved

Also available in: Atom PDF