skip to main content
research-article

A mechanized semantics for C++ object construction and destruction, with applications to resource management

Published:25 January 2012Publication History
Skip Abstract Section

Abstract

We present a formal operational semantics and its Coq mechanization for the C++ object model, featuring object construction and destruction, shared and repeated multiple inheritance, and virtual function call dispatch. These are key C++ language features for high-level system programming, in particular for predictable and reliable resource management. This paper is the first to present a formal mechanized account of the metatheory of construction and destruction in C++, and applications to popular programming techniques such as "resource acquisition is initialization". We also report on irregularities and apparent contradictions in the ISO C++03 and C++11 standards.

Skip Supplemental Material Section

Supplemental Material

popl_8a_2.mp4

References

  1. The Coq proof assistant, 1999--2012. URL http://coq.inria.fr.Google ScholarGoogle Scholar
  2. M. A. Ellis and B. Stroustrup. The Annotated C++ Reference Manual. Addison-Wesley, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. M. Fahndrich and S. Xia. Establishing object invariants with delayed types. In 22nd conf. on Object-Oriented Programming Systems and Applications (OOPSLA'07), pages 337--350. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification. Addison Wesley, 3rd edition edition, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. L. Hubert, T. Jensen, V. Monfort, and D. Pichardie. Enforcing secure object initialization in Java. In Computer Security -- ESORICS 2010, volume 6345 of Lecture Notes in Computer Science, pages 101--115. Springer, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. International Standard ISO/IEC 14882:2003. Programming Languages -- C++. International Organization for Standards, 2003.Google ScholarGoogle Scholar
  7. International Standard ISO/IEC 14882:2011. Programming Languages -- C++. International Organization for Standards, 2011.Google ScholarGoogle Scholar
  8. X. Leroy. A formally verified compiler back-end. Journal of Automated Reasoning, 43 (4): 363--446, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Lockheed Martin. Joint Strike Fighter Air Vehicle C+ Coding Standards for the System Development and Demonstration Program, 2005. URL http://www.research.att.com/ bs/JSF-AV-rules.pdf.Google ScholarGoogle Scholar
  10. M. Norrish. A formal semantics for C+. Technical report, NICTA, 2008.Google ScholarGoogle Scholar
  11. X. Qi and A. C. Myers. Masked types for sound object initialization. In 36th symp. Principles of Programming Languages (POPL'09), pages 53--65. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. T. Ramananandro. phMechanized Formal Semantics and Verified Compilation for C+ Objects. PhD thesis, Université Paris Diderot, Jan. 2012.Google ScholarGoogle Scholar
  13. T. Ramananandro, G. Dos Reis, and X. Leroy. Formal verification of object layout for C+ multiple inheritance. In 38th symp. Principles of Programming Languages (POPL'11), pages 67--80. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. J. G. Rossie and D. P. Friedman. An algebraic semantics of subobjects. In 10th conf. on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'95), pages 187--199. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. B. Stroustrup. Classes: An abstract data type facility for the C language. SIGPLAN Not., 17: 42--51, January 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. B. Stroustrup. phThe design and evolution of C+. ACM Press/Addison-Wesley Publishing Co., New York, NY, USA, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. D. Wasserrab. phFrom Formal Semantics to Verified Slicing -- A Modular Framework with Applications in Language Based Security. PhD thesis, Karlsruher Institut für Technologie, Fakultat für Informatik, Oct. 2010.Google ScholarGoogle Scholar
  18. D. Wasserrab, T. Nipkow, G. Snelting, and F. Tip. An operational semantics and type safety proof for multiple inheritance in C+. In ph21st conf. on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'06), pages 345--362. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A mechanized semantics for C++ object construction and destruction, with applications to resource management

          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

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 47, Issue 1
            POPL '12
            January 2012
            569 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/2103621
            Issue’s Table of Contents
            • cover image ACM Conferences
              POPL '12: Proceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
              January 2012
              602 pages
              ISBN:9781450310833
              DOI:10.1145/2103656

            Copyright © 2012 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 25 January 2012

            Check for updates

            Qualifiers

            • research-article

          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!