Skip to content

Wierd cast when parameter is checked pointer to unchecked pointer #160

Closed
@john-h-kastner

Description

@john-h-kastner

Function arguments are cast to int** when the corresponding parameter is _Ptr<int*>. In the following example, the cast can be removed, and it will still compile.

OriginalConverted
void buz(int **a) {
  *a = (int*)1;
}
void test() {
  int *y;
  buz(&y);
}

void buz(_Ptr<int*> a) {
  *a = (int*)1;
}
void test() {
  int *y;
  buz(((int **)&y));
}

I don't think this has the same underlying issue as #134. The place to start looking is probably this line in GatherTool.cpp.

https://github.com/plum-umd/checkedc-clang/blob/85c92041bd1e058b6781fd9deaa8a0f629e58b8d/clang/lib/CConv/GatherTool.cpp#L36

It considers a parameter WILD if any of its atoms are wild, so a checked pointer to an unchecked pointer is WILD even though the outermost pointer is checked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions