Skip to content

checked-c-convert tool: struct variable containing a checked pointer not initialized #3

Closed

Description

@hasantouma

I noticed this issue when converting the Icecast code. In the file src/avl/avl.c and various others.

The C compiler doesn't complain when a struct variable is not initialized, but the Checked C compiler does. The checked-c-convert tool doesn't give an warnings that an initialized struct variable was seen.

I created a small example for reference:

Original C code:

typedef struct _link_node {
  struct _link_node *parent;
  int width;
} link_node;

int add_to_link_node(link_node *node) {

  node->width += 5;

  return node->width;
}

int main() {

  link_node here;
  here.width = 10;

  return add_to_link_node(&here);
}

checked-c-convert output:

typedef struct _link_node {
  _Ptr<struct _link_node> parent;
  int width;
} link_node;

int add_to_link_node(_Ptr<link_node> node) {

  node->width += 5;

  return node->width;
}

int main() {

  link_node here;
  here.width = 10;

  return add_to_link_node(&here);
}

Running clang on the checked-c-convert output will produce the error:
error: struct variable 'here' containing a checked pointer must have an initializer

Activity

  1. Machiry commented on Jul 13, 2019

    @Machiry
    Collaborator

    A part of this issue is fixed by this commit: 51b6167

  2. added a commit that references this issue on Jul 13, 2019
  3. Machiry commented on Jul 13, 2019

    @Machiry
    Collaborator

    @hasantouma Please pull the branch: https://github.com/plum-umd/checkedc-clang/tree/WIP/IterativeItypeRefinement and test. If the issue is resolved. Please close this issue.

  4. hasantouma commented on Jul 14, 2019

    @hasantouma
    CollaboratorAuthor

    @Machiry Yes, this commit does fix the initialization issue. I'll close this issue now. Thank you.

  5. added 2 commits that reference this issue on Jul 26, 2019
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions