Skip to content

Introduce temporaries for argument expressions that have side-effects and are used in parameter or return bounds #1009

Open
@mattmccutchen-cci

Description

@mattmccutchen-cci

I noticed that the original C source code of one of CCI's 3C benchmark programs (icecast) builds successfully with the Checked C compiler, but after I update the #include directives to reference the checked headers, a Checked C compile error occurs. Here's a simplified test case. The following program compiles:

#include <stdlib.h>

void test() {
  int len = 5;
  char *p = malloc(++len);
}

But if I change the first line to #include <stdlib_checked.h>, then I get the following error:

malloc.c:5:20: error: increment expression not allowed in argument for parameter used in function return bounds expression
  char *p = malloc(++len);
                   ^~~~~

I believe it's a design goal that the Checked C compiler should accept plain C code even when the checked headers are included so that code can be converted gradually even within a single file. If so, the above behavior violates that design goal, and it will become a bigger problem with implicit inclusion of checked headers (checkedc/checkedc#440 et al.), hence my interest in reporting this issue now.

There may be other bugs of this nature. If I can spare the time, I'll run the Checked C compiler on all of our benchmarks after updating the #includes but before adding any actual Checked C annotations, since if that fails, implicit header inclusion would block our workflow unless we opt out of it.

Metadata

Metadata

Assignees

Labels

priority:3This labels bugs that are not very critical but still need to be addressed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions