Skip to content

Wrong output for diff that involves array dimension size  #5

Description

@stan6

The cgum parser causes GumTree to generate wrong output for diffs that involve array dimension size. To verify this bug, I have created two corresponding files in three different programming languages (Java. C, CPP) that differ only in the array dimension declaration.

In the Java version of GumTree, the update of array size is

$diff test.java test1.java
4c4
<     int a[]=new int[5];//declaration and instantiation 
---
>     int a[]=new int[6];//declaration and instantiation

$gumtree jsondiff test.java test1.java
"actions": [
    {
      "action": "update",
      "tree": 16,
      "label": "6"
    }

As can be seen from this example, the array size update in Java programs is shown correctly.

However, the array size update in C programs is not shown correctly.

diff test.c test1.c
4c4
<    char name1[50];
---
>    char name1[51];
```
```
gumtree jsondiff test.c test1.c
"actions": []
```
When I try to rename all the C files to CPP files, then the array size update will be shown correctly because a different parser (srcml) instead of cgum will be invoked instead.
```
gumtree jsondiff test.cpp test1.cpp
"actions": [
    {
      "action": "update",
      "tree": 10,
      "label": "51"
    }
```



Expected Output:
Difference that involves array dimension size should be parsed by cgum and shown correctly in GumTree.

Related Files:
[test.zip](https://github.com/GumTreeDiff/cgum/files/2111764/test.zip)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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