This paper appearedin the Journal of Programming Languages, Vol 2, Num 4, 1994. Quantifying Behavioral Differences Between C and C++ Programs Brad Calder, Dirk Grunwald, and Benjamin Zorn Department of Computer Science Campus Box 430 University of Colorado Boulder, CO 80309–0430 USA calder,grunwald,zorn @cs.colorado.edu March 28, 1995 Abstract Improving the performance of C programs has been a topic of great interest for many years. Both hardware technology and compiler optimization research has been applied in an effort to make C programs execute faster. In many application domains, the C++ language is replacing C as the programming language of choice. In this paper, we measure the empirical behavior of a group of significant C and C++ programs and attempt to identify and quantify behavioral differences between them. Our goal is to investigate whether optimization technology that has been successful for C programs will also be successful in C++ programs. We furthermore identify behavioral characteristics of C++ programs that suggest optimizations that should be applied in those programs. Our results show that C++ programs exhibit behavior that is significantly different than C programs. These results should be of interest to compiler writers and architecture designers who are designing systems to execute object-oriented programs. 1 Introduction The design of computer architecture is typically driven by the needs of various programs and programming languages. A significant amount of research, both in compiler optimization and in architecture design, has been conducted with the specific goal of improving the performance of existing conventional programs [1, 2]. Early studies of program behavior [3, 4, 5, 6] have guided architectural design, and the importance of measurement and simulation has permeated architectural design philosophy [7]. In particular, the IBM 801, Berkeley, and Stanford RISC projects were all guided by studies of C and FORTRAN programs [8]. More recent studies have used the SPEC program suite. This set of programs, widely used to benchmark new hardware platforms and compiler implementations, consists of a mixture of C and FORTRAN programs [9, 10]. More recently, object-oriented programming, and specifically the language C++, has become widely used and is replacing procedural languages such as C in a number of application areas including user-interfaces, data structure libraries, scientific computing [11], and operating systems [12]. While the C++ language is a superset of C, additional features provided in the language support a programming style that is very different from that of programming in C. Before conducting the research reported in this paper, our hypothesis was that C++ programs behave quite differently from C programs and that these differences may have a significant impact on performance. In this paper we investigate the behavior of 12 C++ programs and 11 C programs, including the SPECint92 benchmark suite. While this small sample of programs clearly does not capture the behavior of all C and C++ programs, the sample of programs measured is representative of a variety of common tasks implemented in these languages. Furthermore, our measurements show 1