skip to main content
10.1145/1167473.1167503acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
Article

An operational semantics and type safety prooffor multiple inheritance in C++

Published:16 October 2006Publication History

ABSTRACT

We present an operational semantics and type safety proof for multiple inheritance in C++. The semantics models the behaviour of method calls, field accesses, and two forms of casts in C++ class hierarchies exactly, and the type safety proof was formalized and machine-checked in Isabelle/HOL. Our semantics enables one, for the first time, to understand the behaviour of operations on C++ class hierarchies without referring to implementation-level artifacts such as virtual function tables. Moreover, it can - as the semantics is executable - act as a reference for compilers, and it can form the basis for more advanced correctness proofs of, e.g., automated program transformations. The paper presents the semantics and type safety proof, and a discussion of the many subtleties that we encountered in modeling the intricate multiple inheritance model of C++.

References

  1. David Aspinall. Proof General - a generic tool for proof development. In S. Graf and M. I. Schwartzbach, editors, Tools and Algorithms for Construction and Analysis of Systems, TACAS 2000, volume 1785 of Lect. Notes in Comp. Sci., pages 38--42. Springer-Verlag, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Isabelle Attali, Denis Caromel, and Sidi Ould Ehmety. A natural semantics for Eiffel dynamic binding. ACM TOPLAS, 18(6):711--729, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Stefan Berghofer and Tobias Nipkow. Executing Higher Order Logic. In P. Callaghan, Z. Luo, J. McKinna, and R. Pollack, editors, Types for Proofs and Programs (TYPES 2000), volume 2277 of LNCS. Springer-Verlag, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Gilad Bracha and William Cook. Mixin-based inheritance. In Proc. of OOPSLA/ECOOP'90, pages 303--311, 1990.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. V. Breazu-Tannen, C. A. Gunter, and A. Scedrov. Computing with coercions. In Proc. ACM Conf. LISP and functional programming, pages 44--60. ACM Press, 1990.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Luca Cardelli. A semantics of multiple inheritance. Information and Computation, 76:138--164, 1988.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Luca Cardelli. Type systems. In The Computer Science and Engineering Handbook. 2 edition, 2004.]]Google ScholarGoogle Scholar
  8. Sophia Drossopoulou and Susan Eisenbach. Java is type safe - probably. In Proc. of ECOOP'97, volume 1241 of Lect. Notes in Comp. Sci., pages 389--418, 1997.]]Google ScholarGoogle Scholar
  9. Michale Hohmuth and Hendrik Tews. The semantics of C++ data types: Towards verifying low-level system components. In D. Basin and B. Wolff, editors, Theorem Proving in Higher Order Logics, Emerging Trends Proc., pages 127--144. Universität Freiburg, 2003. Tech. Rep. 187.]]Google ScholarGoogle Scholar
  10. Paul Jolly, Sophia Drossopoulou, Christopher Anderson, and KlausOstermann. Simple dependent types: Concord. In Proc. of FTfJP'05, 2005.]]Google ScholarGoogle Scholar
  11. Gerwin Klein and Tobias Nipkow. A machine-checked model for a Java-like language, virtual machine and compiler. ACM TOPLAS, 28(4):619--695, 2006.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Henry Lieberman. Using prototypical objects to implement shared behavior in object-oriented systems. In Proc. of OOPSLA'86, pages 214--223, 1986.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Ole Lehrmann Madsen and Birger Moeller-Pedersen. Virtual classes: A powerful mechanism in object-oriented programming. In Proc. of OOPSLA'89, pages 397--406, 1989.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17(3):348--375, 1978.]]Google ScholarGoogle Scholar
  15. Tobias Nipkow, Lawrence Paulson, and Markus Wenzel. Isabelle/HOL - A Proof Assistant for Higher-Order Logic, volume 2283 of Lect. Notes in Comp. Sci. 2002. http://www.in.tum.de/~nipkow/LNCS2283/.]]Google ScholarGoogle Scholar
  16. Nathaniel Nystrom, Stephen Chong, and Andrew C. Myers. Scalable extensibility via nested inheritance. In Proc. of OOPSLA'04, pages 99--115, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Martin Odersky, Philippe Altherr, Vincent Cremet, Burak Emir, Sebastian Maneth, Stéphane Micheloud, Nikolay Mihaylov, Michel Schinz, Erik Stenman, and Matthias Zenger. An overview of the Scala programming language. Technical Report IC/2004/64, école Polytechnique Fédérale de Lausanne, Lausanne, Switzerland, 2004. Available from scala.epfl.ch.]]Google ScholarGoogle Scholar
  18. Martin Odersky, Vincent Cremet, Christine Röckl, and Matthias Zenger. A nominal theory of objects with dependent types. In Proc. of ECOOP'03.]]Google ScholarGoogle Scholar
  19. Benjamin C. Pierce. Types and Programming Languages. The MIT Press, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. G. Ramalingam and Harini Srinivasan. A member lookup algorithm for C++. In Proc. of PLDI '97, pages 18--30, 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Jonathan G. Rossie, Jr. and Daniel P. Friedman. An algebraic semantics of subobjects. In Proc. of OOPSLA'95, pages 187--199. ACM Press, 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Jonathan G. Rossie, Jr., Daniel P. Friedman, and Mitchell Wand. Modeling subobject-based inheritance. In Proc. of ECOOP'96, volume 1098 of Lect. Notes in Comp. Sci., pages 248--274, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Adam Seligman. FACTS: A formal analysis for C++. Williams College, 1995. Undergraduate thesis.]]Google ScholarGoogle Scholar
  24. Gregor Snelting and Frank Tip. Understanding class hierarchies using concept analysis. ACM TOPLAS, pages 540--582, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Gregor Snelting and Frank Tip. Semantics-based composition of class hierarchies. In Proc. of ECOOP'02, volume 2374 of Lect. Notes in Comp. Sci., pages 562--584, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Mirko Streckenbach and Gregor Snelting. Refactoring Class Hierarchies with KABA. In Proc. of OOPSLA'04, pages 315--330, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Bjarne Stroustrup. Multiple inheritance for C++. Computing Systems, 2(4), 1989.]]Google ScholarGoogle Scholar
  28. Bjarne Stroustrup. The Design and Evolution of C++. Addison Wesley, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Bjarne Stroustrup. The C++ Standard: Incorporating Technical Corrigendum No. 1. John Wiley, 2 edition, 2003.]]Google ScholarGoogle Scholar
  30. Peter F. Sweeney and Michael G. Burke. Quantifying and evaluating the space overhead for alternative C++ memory layouts. Software: Practice and Experience, 33(7):595--636, 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Peter F. Sweeney and Joseph Gil. Space and time-efficient memory layout for multiple inheritance. In Proc. of OOPSLA'99, pages 256--275, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Ewan Tempero and Robert Biddle. Simulating multiple inheritance in Java. Journal of Systems and Software, 55:87--100, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Krishnaprasad Thirunarayan, Günter Kniesel, and Haripriyan Hampapuram. Simulating multiple inheritance and generics in Java. Computer Languages, 25:189--210, 1999.]]Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Frank Tip and Peter Sweeney. Class hierarchy specialization. Acta Informatica, 36:927--982, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. John Viega, Bill Tutt, and Reimer Behrends. Automated delegation is a viable alternative to multiple inheritance in class based languages. Technical Report CS-98-3, University of Virginia, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Charles Wallace. The semantics of the C++ programming language. In E. Börger, editor, Specification and Validation Methods, pages 131--164. Oxford University Press, 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Daniel Wasserrab, Tobias Nipkow, Gregor Snelting, and Frank Tip. An Operational Semantics and Type Safety Proof for C++-like Multiple Inheritance. Technical Report RC23709, IBM, 2005.]]Google ScholarGoogle Scholar
  38. Markus Wenzel. Isabelle/Isar - A Versatile Environment for Human-Readable Formal Proof Documents. PhD thesis, Institut für Informatik, Technische Universität München, 2002. http://tumb1.biblio.tu-muenchen.de/publ/diss/in/2002/wenzel.html.]]Google ScholarGoogle Scholar
  39. Andrew K. Wright and Matthias Felleisen. A syntactic approach to type soundness. Information and Computation, (115):38--94, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Yoav Zibin and Joseph Gil. Two-dimensional bi-directional object layout. In Proc. of ECOOP'03, volume 3013 of Lect. Notes in Comp. Sci., pages 329--350, 2003.]]Google ScholarGoogle Scholar

Index Terms

  1. An operational semantics and type safety prooffor multiple inheritance in C++

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!