cpg icon indicating copy to clipboard operation
cpg copied to clipboard

Unexpected C function call representation if function called `new`

Open fwendland opened this issue 3 years ago • 1 comments

I have the following C code:

#include <stdlib.h>

struct s {
    int a;
};

typedef struct s S;


S* new() {
    return malloc(sizeof(S));
}

void fun() {
    S *sptr = new();
}

I've used the Neo4j tool to get an idea to get an idea how the code looks: def-c-neo4j

The large node is a CallExpression. It should represent the function call to new().

What is surprising is:

  • function call is in the function fun(). Why isn't the node part of the EOG of fun?
  • the function code contains as code only (). What happened to its name?

fwendland avatar Jun 28 '21 14:06 fwendland

The problem goes away, when the function isn't called new() if that helps. However, new() is a valid C function name without special meaning afaik.

def-c-ne04j-notnew

fwendland avatar Jun 28 '21 15:06 fwendland