cpp-to-dafny-translator

Translate C++ functions into Dafny with pointers and bitvectors.

1|2|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/santosomar/general-secure-coding-agent-skills --skill cpp-to-dafny-translator-santosomar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-to-dafny-translator
Source: https://github.com/santosomar/general-secure-coding-agent-skills/tree/main/skills/verification/cpp-to-dafny-translator
Command: npx skills add https://github.com/santosomar/general-secure-coding-agent-skills --skill cpp-to-dafny-translator-santosomar

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of formally verifying C++ code by translating it into Dafny, a language designed for specification and verification. It helps ensure the absence of critical bugs like overflows and out-of-bounds access in C++ algorithms.

Core Features & Use Cases

  • C++ to Dafny Translation: Converts C++ functions, including those with pointers, fixed-width integers, and manual memory management, into equivalent Dafny code.
  • Formal Verification: Enables the use of Dafny's powerful verification engine to prove properties about C++ algorithms, such as overflow safety and memory access correctness.
  • Use Case: When developing safety-critical C++ code, use this Skill to generate a verified Dafny model that can be used to prove the absence of runtime errors.

Quick Start

Translate the provided C++ function into Dafny for formal verification.

Frequently Asked Questions about cpp-to-dafny-translator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I formally verify C++ code for memory safety and integer overflow?

To formally verify C++ code for memory safety and integer overflow, you can translate C++ functions into Dafny. This process models pointers and fixed-width integers as Dafny heap objects and bitvectors to prove algorithm correctness.

How are C++ pointers and manual memory management handled when translating to Dafny?

When translating C++ to Dafny, pointers and manual memory management are handled by mapping them to Dafny heap objects. This mapping addresses C++ specific impedance mismatches like pointer arithmetic and manual memory allocation.

Can I use Dafny to prove the absence of out-of-bounds access in C++ algorithms?

Yes, you can use Dafny to prove the absence of out-of-bounds access in C++ algorithms. By generating a verified Dafny model from your C++ code, Dafny's verification engine can prove properties about memory access correctness.

What is the best way to translate fixed-width integers from C++ for formal verification?

The best way to translate fixed-width integers from C++ for formal verification is to map them to Dafny bitvectors. This approach handles integer wrapping and requires explicit proof obligations to verify overflow safety.

Do I need to manually write proof obligations when converting C++ to Dafny?

Yes, translating C++ to Dafny requires explicit proof obligations to handle C++ specific impedance mismatches like integer wrapping and pointer arithmetic. These obligations are necessary to formally verify the absence of runtime errors.

When should I translate safety-critical C++ code to Dafny?

You should translate safety-critical C++ code to Dafny when you need to build verified references and mathematically prove the absence of critical bugs. This is ideal for verifying algorithms where overflow safety and memory access correctness are strictly required.