[changeset] uninitialized value bug in strncmp

Ben Abbott bpabbott at mac.com
Thu Jan 1 07:53:15 CST 2009


On Jan 1, 2009, at 7:20 AM, Thorsten Meyer wrote:

> Hi,
>
> here is a patch (against mercurial) for the following bug in strncmp:
>
> comparing a string with a cell array, the return value for non- 
> character cells is random:
>
> octave:1> strncmp("abc", {"abcd", 10}, 2)
> ans =
>
>     1   164
>
> octave:2>
> octave:2> strncmp("abc", {"abcd", 10}, 2)
> ans =
>
>     1   191
>
> octave:3> strncmp("abc", {"abcd", 10}, 2)
> ans =
>
>     1   184
>
> octave:4> strncmp("abc", {"abcd", 10}, 2)
> ans =
>
>     1   138
>
> The reason is that in this particular case, the output value is left  
> uninitialized.
>
> regards
>
> Thorsten

Strange ... running the developer's sources, I get

octave:1> strncmp('abc', {'abcd', 10}, 2)
ans =

    1   0

octave:2> strncmp('abc', {'abcd', 10}, 2)
ans =

    1   0

octave:3> strncmp('abc', {'abcd', 10}, 2)
ans =

    1   0

octave:4> strncmp('abc', {'abcd', 10}, 2)
ans =

    1   0

I haven't build octave in about a week, but I don't see where this  
code has changed in the last 14 months.

Ben



More information about the Bug-octave mailing list