Write output only after successful compilation

Open Beginner friendly
#6 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
build-system

Research direction

Start in compiler/main.cpp and trace where the output stream is opened relative to assembly validation and the final write. Check the compiler's existing validation path and how it reports failures. Move output creation until validation succeeds; confirm invalid input leaves an existing output untouched and successful compilation writes the expected output.

Written by the indexing model from the issue text.

Description

bug copilot enhancement

Summary

The compiler opens the output file before it has finished validating the assembly and before it knows whether the program is valid.

Problem

If parsing fails, the program may leave an existing output file partially or incorrectly initialized, even though no successful compilation happened.

Expected behavior

  • Validate the entire source before opening or writing the output file.
  • Keep the output file closed until a successful compile is confirmed.
  • Prefer a temp-file-and-rename strategy for safer writes.

Relevant code

  • compiler/main.cpp where the output stream is created before validation completes.

Suggested fix

Move std::ofstream output_file(output); to just before the final write, after all validation passes. Use a temporary output path and rename it on success if atomic updates are important.

Dominant language
C++
Stars
0
Forks
0
Avg merge
1m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DavidSkillman/LittleManCompiler

All issues in DavidSkillman/LittleManCompiler

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.