Skip to content

Expression locations for parts of for loop are sometimes wrong #183

@sim642

Description

@sim642

Increment part has (offset) initializer location

    for (int *p = NULL; 1; (*p)++) {}

Actual Goblint warning is

[Error][Behavior > Undefined > NullPointerDereference][CWE-476] Must dereference NULL pointer (bar.c:5:14-5:22)
      for (int *p = NULL; 1; (*p)++) {}
               ^^^^^^^^

Expected Goblint warning would be

[Error][Behavior > Undefined > NullPointerDereference][CWE-476] Must dereference NULL pointer (bar.c:5:28-5:34)
      for (int *p = NULL; 1; (*p)++) {}
                             ^^^^^^

Increment part has (offset) entire location

    int *p;
    for (p = NULL; 1; (*p)++) {}

Actual Goblint warning is

[Error][Behavior > Undefined > NullPointerDereference][CWE-476] Must dereference NULL pointer (bar.c:8:9-8:28)
      for (p = NULL; 1; (*p)++) {}
          ^^^^^^^^^^^^^^^^^^^

Expected Goblint warning would be

[Error][Behavior > Undefined > NullPointerDereference][CWE-476] Must dereference NULL pointer (bar.c:8:23-8:29)
      for (p = NULL; 1; (*p)++) {}
                        ^^^^^^

Condition part has (offset) entire location

    for (int *p = NULL; (*p)++; (*p)++) {}

Actual Goblint warning (in addition to above) is

[Error][Behavior > Undefined > NullPointerDereference][CWE-476] Must dereference NULL pointer (bar.c:6:9-6:38)
      for (int *p = NULL; (*p)++; (*p)++) {}
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expected Goblint warning would be

[Error][Behavior > Undefined > NullPointerDereference][CWE-476] Must dereference NULL pointer (bar.c:6:25-6:31)
      for (int *p = NULL; (*p)++; (*p)++) {}
                          ^^^^^^

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions