The following code segfaults whenever I use short-circuit-or (|), and compiles flawlessly when not short-circuited (||)?
Compiled using gcc -Wall ../IsNull/IsNull.c ../IsEmpty/IsEmpty.c *.c -o IsNullOrEmpty:
#include <stdbool.h>
#include "../IsNull/IsNull.h"
#include "../IsEmpty/IsEmpty.h"
#include "IsNullOrEmpty.h"
_Bool isNullOrEmpty (char *str);
_Bool isNullOrEmpty (char *str) {
return (isNull (str) | isEmpty (str));
} /* end of isNullOrEmpty() */
You should be using
||(logical or operator) instead of|(bitwise or operator). The former short-circuits whilst the latter does not, hence the segmentation fault.