Skip to content

Commit

Permalink
src: silence compiler warning node_process_methods
Browse files Browse the repository at this point in the history
Currently, the following compiler warning is generated by clang:
../src/node_process_methods.cc:71:3:
warning: indirection of non-volatile null pointer will be deleted,
not trap [-Wnull-dereference]
  *static_cast<volatile void**>(nullptr) = nullptr;
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/node_process_methods.cc:71:3: note:
consider using __builtin_trap() or qualifying pointer with 'volatile'
1 warning generated.

This commit adds the volatile qualifier to avoid this warning.

PR-URL: nodejs#28261
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
danbev authored and addaleax committed Jun 19, 2019
1 parent 05b8526 commit 264cb79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/node_process_methods.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ static void Abort(const FunctionCallbackInfo<Value>& args) {
// For internal testing only, not exposed to userland.
static void CauseSegfault(const FunctionCallbackInfo<Value>& args) {
// This should crash hard all platforms.
*static_cast<void**>(nullptr) = nullptr;
volatile void** d = static_cast<volatile void**>(nullptr);
*d = nullptr;
}

static void Chdir(const FunctionCallbackInfo<Value>& args) {
Expand Down

0 comments on commit 264cb79

Please sign in to comment.