No segfault -> null == ""
Sergey Gromov
snake.scaly at gmail.com
Tue Mar 31 11:34:55 PDT 2009
Tue, 31 Mar 2009 16:29:30 +0200, Qian Xu wrote:
> When I was trying to learn how char-array works, I found something
> unexpected.
>
> -------------------------- code ------------------------------
> module string_test;
>
> void main()
> {
> // test 1
> assert(null == "", "null is empty"); // No segfault
When you compare null to an array, null is first converted into an empty
array, then a comparison takes place. This happens because arguments to
comparison operator are first converted to a common type.
More information about the Digitalmars-d-learn
mailing list