skip to main content
10.1145/2103656.2103719acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

An executable formal semantics of C with applications

Published:25 January 2012Publication History

ABSTRACT

This paper describes an executable formal semantics of C. Being executable, the semantics has been thoroughly tested against the GCC torture test suite and successfully passes 99.2% of 776 test programs. It is the most complete and thoroughly tested formal definition of C to date. The semantics yields an interpreter, debugger, state space search tool, and model checker "for free". The semantics is shown capable of automatically finding program errors, both statically and at runtime. It is also used to enumerate nondeterministic behavior.

Skip Supplemental Material Section

Supplemental Material

popl_8a_3.mp4

mp4

223.1 MB

References

  1. S. Blazy and X. Leroy. Mechanized semantics for the Clight subset of the C language. Journal Of Automated Reasoning, 43 (3): 263--288, 2009.Google ScholarGoogle ScholarCross RefCross Ref
  2. R. S. Boyer and J. S. Moore. A Computational Logic Handbook. Academic Press, second edition, 1998.Google ScholarGoogle Scholar
  3. M. Clavel, F. Durán, S. Eker, J. Meseguer, P. Lincoln, N. Martı-Oliet, and C. Talcott. All About Maude, A High-Performance Logical Framework, volume 4350 of LNCS. Springer, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. V. Cook and S. Subramanian. A formal semantics for C in Nqthm. Technical Report 517D, Trusted Information Systems, November 1994.Google ScholarGoogle Scholar
  5. J. V. Cook, E. L. Cohen, and T. S. Redmond. A formal denotational semantics for C. Technical Report 409D, Trusted Information Systems, September 1994.Google ScholarGoogle Scholar
  6. P. Cuoq, J. Signoles, P. Baudin, R. Bonichon, G. Canet, L. Correnson, B. Monate, V. Prevosto, and A. Puccetti. Experience report: OCaml for an industrial-strength static analysis framework. SIGPLAN Not., 44: 281--286, August 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. T. Duff. On Duff's device, 1988. URL http://www.lysator.liu.se/c/duffs-device.html. Msg. to the comp.lang.c Usenet group.Google ScholarGoogle Scholar
  8. C. Ellison, T. F. Serbanuta, and G. Rosu. A rewriting logic approach to type inference. In 19th International Workshop on Algebraic Development Techniques (WADT'08), volume 5486 of LNCS, pages 135--151, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. F. GNU compiler collection, 2010. URL http://gcc.gnu.org.Google ScholarGoogle Scholar
  10. F. C language testsuites: "C-torture" version 4.4.2, 2010. URL http://gcc.gnu.org/onlinedocs/gccint/C-Tests.html.Google ScholarGoogle Scholar
  11. Y. Gurevich and J. K. Huggins. The semantics of the C programming language. In Computer Science Logic, volume 702 of LNCS, pages 274--308, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. D. R. Hanson and C. W. Fraser. A Retargetable C Compiler: Design and Implementation. Addison-Wesley, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. JTC 1, SC 22, WG 14. ISO/IEC 9899:1999: Programming languages--C. Technical Report n1256, International Organization for Standardization, December 1999.Google ScholarGoogle Scholar
  14. ISO/IEC JTC 1, SC 22, WG 14. Rationale for international standard--programming languages--C. Technical Report 5.10, International Organization for Standardization, April 2003.Google ScholarGoogle Scholar
  15. ISO/IEC JTC 1, SC 22, WG 14. ISO/IEC 9899:201x: Programming languages--C. Technical Report n1570, International Organization for Standardization, August 2011.Google ScholarGoogle Scholar
  16. D. M. Jones. The New C Standard: An Economic and Cultural Commentary. Self-published, December 2008. URL http://www.knosof.co.uk/cbook/cbook.html.Google ScholarGoogle Scholar
  17. B. W. Kernighan and D. M. Ritchie. The C Programming Language. Prentice Hall, second edition, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. J. Meseguer. Conditional rewriting logic as a unified model of concurrency. Theoretical Computer Science, 96 (1): 73--155, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. G. C. Necula, S. McPeak, S. P. Rahul, and W. Weimer. CIL: Intermediate language and tools for analysis and transformation of C programs. In International Conference on Compiler Construction, pages 213--228, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Nita, D. Grossman, and C. Chambers. A theory of platform-dependent low-level software. In 35th ACM Symposium on Principles of Programming Languages (POPL'08), 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. L. C. Noll, S. Cooper, P. Seebach, and L. A. Broukhis. The international obfuscated C code contest, 2010. URL http://www.ioccc.org/.Google ScholarGoogle Scholar
  22. M. Norrish. C formalised in HOL. Technical Report UCAM-CL-TR-453, University of Cambridge, December 1998.Google ScholarGoogle Scholar
  23. M. Norrish. A formal semantics for CC. Technical report, NICTA, 2008. URL http://nicta.com.au/people/norrishm/attachments/bibliographies_and_papers/C-TR.pdf.Google ScholarGoogle Scholar
  24. N. S. Papaspyrou. A Formal Semantics for the C Programming Language. PhD thesis, \National Technical University of Athens, 1998.Google ScholarGoogle Scholar
  25. N. S. Papaspyrou. Denotational semantics of ANSI C. Computer Standards and Interfaces, 23 (3): 169--185, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. N. S. Papaspyrou and D. Maćos. A study of evaluation order semantics in expressions with side effects. Journal Of Functional Programming, 10 (3): 227--244, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. G. D. Plotkin. The origins of structural operational semantics. Journal Of Logic and Algebraic Programming, 60: 60--61, 2004.Google ScholarGoogle Scholar
  28. G. Rosu and T. F. Serbanuta. An overview of the K semantic framework. Journal Of Logic and Algebraic Programming, 79 (6): 397--434, 2010.Google ScholarGoogle ScholarCross RefCross Ref
  29. G. Rosu and A. Stefanescu. Matching logic: A new program verification approach (NIER track). In 30th International Conference on Software Engineering (ICSE'11), pages 868--871, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. G. Rosu, W. Schulte, and T. F. Serbanuta. Runtime verification of C memory safety. In Runtime Verification (RV'09), volume 5779 of LNCS, pages 132--152, 2009.Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. G. Rosu, C. Ellison, and W. Schulte. Matching logic: An alternative to Hoare/Floyd logic. In 13th International Conference on Algebraic Methodology and Software Technology (AMAST'10), volume 6486 of LNCS, pages 142--162, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. T. F. Serbanuta and G. Rosu. K-Maude: A rewriting based tool for semantics of programming languages. In 8th International Workshop on Rewriting Logic and its Applications (WRLA'09), volume 6381 of LNCS, pages 104--122, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. Subramanian and J. V. Cook. Mechanical verification of C programs. In ACM SIGSOFT Workshop on Formal Methods in Software Practice, January 1996.Google ScholarGoogle Scholar
  34. S. Summit. C programming FAQs: Frequently asked questions, 2005. URL http://www.c-faq.com/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. X. Yang, Y. Chen, E. Eide, and J. Regehr. Finding and understanding bugs in C compilers. In 32nd Conference on Programming Language Design and Implementation (PLDI'11), pages 283--294, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. W. Zimmermann and A. Dold. A framework for modeling the semantics of expression evaluation with abstract state machines. In Abstract State Machines, volume 2589 of LNCS, pages 391--406, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. An executable formal semantics of C with applications

      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
      • Published in

        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
        • 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

        Copyright © 2012 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 25 January 2012

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Author Tags

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate824of4,130submissions,20%

        Upcoming Conference

        POPL '25

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader