aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorbobsayshilol <bobsayshilol@live.co.uk>2024-10-27 20:11:42 +0000
committerbobsayshilol <bobsayshilol@live.co.uk>2024-10-27 22:02:34 +0000
commitc1496ab6c055974ac401865bdca87a4fc0a76ea3 (patch)
treefd7a6f33af78b224030517c634cdfdc573dab985 /src/parser.cpp
parent4f800a7fdaaa430226108e3bb2bf9fafbda41be8 (diff)
Fix passing nullptr to args marked as non-null
libstdc++'s |memcpy| and |memset| both state that their inputs should never be a nullptr since this matches the C spec. Some compilers act on these hints, so we shouldn't unconditionally call these as it would signal to the compiler that they can't be nullptrs. As an example, the following code will always call |do_something()| when compiled with optimisations since GCC version 4.9: ``` void clear(void *ptr, int size) { memset(ptr, 0, size); } void example(void *ptr, int size) { clear(ptr, size); if (ptr != nullptr) do_something(); } ```
Diffstat (limited to 'src/parser.cpp')
0 files changed, 0 insertions, 0 deletions