This is the primary development repository for 3C, a tool for automatically converting legacy C code to the Checked C extension of C, which aims to enforce spatial memory safety. This repository is a fork of Checked C's.
14
stars
5
forks
source link
`-itypes-for-extern` rewrites itype parameters even when they don't need to be changed #715
When converted with 3c -itypes-for-extern, the function is rewritten even though it hasn't changed.
This can break idempotence in some situations:
#define foo int
void test(foo *a) {}
converts (3c -itypes-for-extern) to
#define foo int
void test(int *a : itype(_Ptr<foo>)) {}
but a further pass through 3c gives
#define foo int
void test(int *a : itype(_Ptr<int>)) {}
A fix should be fairly straight forward. The condition for rewriting with an itype under -itypes-for-extern just needs to have a srcHasItype check. Alternatively, a fix could come via the change suggested by matt here (update: now filed as #740). If the internal constraint solves to WILD, and the special casing in the rewriter is removed, the main itype rewriting logic will correctly notice the existing itype and not rewrite.
For example:
When converted with
3c -itypes-for-extern
, the function is rewritten even though it hasn't changed.This can break idempotence in some situations:
converts (
3c -itypes-for-extern
) tobut a further pass through 3c gives
A fix should be fairly straight forward. The condition for rewriting with an itype under
-itypes-for-extern
just needs to have asrcHasItype
check. Alternatively, a fix could come via the change suggested by matt here (update: now filed as #740). If the internal constraint solves to WILD, and the special casing in the rewriter is removed, the main itype rewriting logic will correctly notice the existing itype and not rewrite.