Physical type checking for C

The eeectiveness of traditional type checking in C is limited by the presence of type conversions using type casts. Because the C standard allows arbitrary type conversions between pointer types, neither C compilers, nor tools such as lint, can guarantee type safety in the presence of such type conversions. In particular, by using casts involving pointers to structures (C structs), a programmer can interpret any memory region to be of any desired type, further compromising C's weak type system. Not only do type casts make program vulnerable to type errors, they hinder program comprehension and maintenance by creating latent dependencies between seemingly independent pieces of code. To address these problems, we have developed a stronger form of type checking for C programs, called physical type checking. Physical type checking takes into account the layout of C struct elds in memory. This paper describes an inference-based physical type checking algorithm and its implementation. Our algorithm can be used to perform static safety checks, as well as compute useful information for software engineering applications.

[1]  Yanhong A. Liu,et al.  Dependence analysis for recursive data , 1998, Proceedings of the 1998 International Conference on Computer Languages (Cat. No.98CB36225).

[2]  Philip Wadler,et al.  Projections for strictness analysis , 1987, FPCA.

[3]  Alexander Aiken,et al.  Program Analysis Using Mixed Term and Set Constraints , 1997, SAS.

[4]  Thomas W. Reps,et al.  Program Specialization via Program Slicing , 1996, Dagstuhl Seminar on Partial Evaluation.

[5]  Susan Horwitz,et al.  Fast and accurate flow-insensitive points-to analysis , 1997, POPL '97.

[6]  Luca Cardelli,et al.  A Semantics of Multiple Inheritance , 1984, Inf. Comput..

[7]  S LamMonica,et al.  Efficient context-sensitive pointer analysis for C programs , 1995 .

[8]  Satish Chandra,et al.  Coping with type casts in C , 1999, ESEC/FSE-7.

[9]  Thomas W. Reps,et al.  Pointer analysis for programs with structures and casting , 1999, PLDI '99.

[10]  Thomas W. Reps,et al.  Program generalization for software reuse: from C to C++ , 1996, SIGSOFT '96.

[11]  Barbara G. Ryder,et al.  Program decomposition for pointer aliasing: a step toward practical analyses , 1996, SIGSOFT '96.

[12]  Geoffrey Smith,et al.  Towards an ML-Style Polymorphic Type System for C , 1996, ESOP.

[13]  Gregor Snelting,et al.  Polymorphic components for monomorphic languages , 1993, [1993] Proceedings Advances in Software Reuse.

[14]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[15]  A. Aiken,et al.  Flow-Insensitive Points-to Analysis with Term and Set Constraints , 1997 .

[16]  Robert D. Tennent,et al.  Semantics of programming languages , 1991, Prentice Hall International Series in Computer Science.

[17]  Frank Tip,et al.  Aggregate structure identification and its application to program analysis , 1999, POPL '99.

[18]  Bjarne Steensgaard Points-to Analysis by Type Inference of Programs with Structures and Unions , 1996, CC.