I think the most likely explanation is that your dirsize variable is empty.
For example, in bash
$ foo=3; bar= ; echo $(( $foo + $bar ))
bash: 3 + : syntax error: operand expected (error token is "+ ")
while in AT&T ksh
$ foo=3; bar= ; echo $(( $foo + $bar ))
ksh: 3 + : more tokens expected
and in BSD mksh
$ foo=3; bar= ; echo $(( $foo + $bar ))
mksh: 3 + : unexpected 'end of expression'
Note that all of these shells allow "bare" variable names like (( foo + bar )) in expressions, and this form may be preferable since it treats empty variables as zero values. From man bash:
Shell variables are allowed as operands; parameter expansion is per‐
formed before the expression is evaluated. Within an expression, shell
variables may also be referenced by name without using the parameter
expansion syntax. A shell variable that is null or unset evaluates to
0 when referenced by name without using the parameter expansion syntax.
So for example
$ foo=3; bar=7 ; echo $(( foo + bar ))
10
$ foo=3; bar= ; echo $(( foo + bar ))
3