Skip to content

Commit 38861be

Browse files
committed
Use __builtin_trap instead of null pointer dereference to abort
This fixes a warning from Apple's clang compiler: [ 34%] Building CXX object CMakeFiles/libtesseract.dir/src/ccutil/errcode.cpp.o /Users/travis/build/stweil/tesseract/src/ccutil/errcode.cpp:83:7: warning: indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference] *reinterpret_cast<int*>(0) = 0; ^~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/travis/build/stweil/tesseract/src/ccutil/errcode.cpp:83:7: note: consider using __builtin_trap() or qualifying pointer with 'volatile' Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 4bd18c4 commit 38861be

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ccutil/errcode.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,14 @@ const char *format, ... // special message
7777
//err_exit();
7878
case ABORT:
7979
#if !defined(NDEBUG)
80-
// Create a deliberate segv as the stack trace is more useful that way.
81-
// This is done only in debug builds, because the error message
82-
// "segmentation fault" confuses most normal users.
80+
// Create a deliberate abnormal exit as the stack trace is more useful
81+
// that way. This is done only in debug builds, because the
82+
// error message "segmentation fault" confuses most normal users.
83+
#if defined(__GNUC__)
84+
__builtin_trap();
85+
#else
8386
*reinterpret_cast<int*>(0) = 0;
87+
#endif
8488
#endif
8589
abort();
8690
default:

0 commit comments

Comments
 (0)