diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-05-26 21:11:16 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-07-05 09:31:44 +0200 |
commit | 211c4518903d82068c061943064824ac5595fd38 (patch) | |
tree | 5c332554f6df617d5d9d9eb81f1e471517231fbf /core/list.h | |
parent | 9fa4f1c54c6d528192e7ed04354d5ce2c733d99a (diff) | |
download | redot-engine-211c4518903d82068c061943064824ac5595fd38.tar.gz |
Implement well-defined handling of unrecoverable errors
Plus the addition of some convenience CRASH_* error macros.
Plus transient avoidance of the flood of warnings emitted by Clang when checking 'this' for NULL.
Plus explanation about the do-while(0) loop in some error macros.
Diffstat (limited to 'core/list.h')
-rw-r--r-- | core/list.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/core/list.h b/core/list.h index 4390cb65fc..df69b1dc40 100644 --- a/core/list.h +++ b/core/list.h @@ -398,10 +398,7 @@ public: T &operator[](int p_index) { - if (p_index < 0 || p_index >= size()) { - T &aux = *((T *)0); //nullreturn - ERR_FAIL_COND_V(p_index < 0 || p_index >= size(), aux); - } + CRASH_BAD_INDEX(p_index, size()); Element *I = front(); int c = 0; @@ -415,15 +412,12 @@ public: c++; } - ERR_FAIL_V(*((T *)0)); // bug!! + CRASH_NOW(); // bug!! } const T &operator[](int p_index) const { - if (p_index < 0 || p_index >= size()) { - T &aux = *((T *)0); //nullreturn - ERR_FAIL_COND_V(p_index < 0 || p_index >= size(), aux); - } + CRASH_BAD_INDEX(p_index, size()); const Element *I = front(); int c = 0; @@ -437,7 +431,7 @@ public: c++; } - ERR_FAIL_V(*((T *)0)); // bug! + CRASH_NOW(); // bug!! } void move_to_back(Element *p_I) { |