Skip to content

Verifier Error / Incorrect comparisons against result of len() function #3308

Closed
@ajor

Description

@ajor

This script should print "true":

BEGIN
{
  @[1] = 1;
  @[2] = 2;

  $count = len(@);
  // Uncomment this line and it works
  //$count = 2;

  printf("count: %d\n", $count);

  if ($count > 1) {
    print("true");
  } else {
    print("false");
  }

  printf("count: %d\n", $count);

  clear(@);
  exit();
}

Output:

Attaching 1 probe...
count: 2
false
count: 2

We can see that $count holds the value 2 (as expected), but this value does not evaluate as greater than 1 for some reason.
If we use the literal 2 instead of the result of len(@), then we get the expected result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions