Fix binding of null pointer dereference to reference type

A new Clang warning complains about this, and especially for the function
returning a reference, it seems like a bad idea.

BUG=none

Review-Url: https://codereview.chromium.org/1986453002
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h
index 7121ffc..59d72b8 100644
--- a/core/fxcrt/include/fx_basic.h
+++ b/core/fxcrt/include/fx_basic.h
@@ -277,7 +277,7 @@
 
   const TYPE GetAt(int nIndex) const {
     if (nIndex < 0 || nIndex >= m_nSize) {
-      return (const TYPE&)(*(volatile const TYPE*)NULL);
+      PDFIUM_IMMEDIATE_CRASH();
     }
     return ((const TYPE*)m_pData)[nIndex];
   }
@@ -292,7 +292,7 @@
 
   TYPE& ElementAt(int nIndex) {
     if (nIndex < 0 || nIndex >= m_nSize) {
-      return *(TYPE*)NULL;
+      PDFIUM_IMMEDIATE_CRASH();
     }
     return ((TYPE*)m_pData)[nIndex];
   }
diff --git a/core/fxcrt/include/fx_system.h b/core/fxcrt/include/fx_system.h
index 205976f..61acd73 100644
--- a/core/fxcrt/include/fx_system.h
+++ b/core/fxcrt/include/fx_system.h
@@ -103,6 +103,12 @@
 #endif
 #endif
 
+#if defined(__clang__) || defined(__GNUC__)
+#define PDFIUM_IMMEDIATE_CRASH() __builtin_trap()
+#else
+#define PDFIUM_IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0))
+#endif
+
 // M_PI not universally present on all platforms.
 #define FX_PI 3.1415926535897932384626433832795f
 #define FX_BEZIER 0.5522847498308f