r/cpp

▲ 32 r/cpp

C++26 ends a 40-year footgun

Reading an uninitialized variable has been undefined behavior in C++ for 40 years -- the kind optimizers exploit into real bugs. C++26 (P2795) reclassifies it as erroneous behavior: still a bug, still warned about, but defined, bounded, and not exploitable.

The demo poisons the stack, then reads an uninitialized int. As C++23 it prints garbage; as C++26, the same code prints a defined 0, every run. Live in your browser.

And [[indeterminate]] lets you opt back out when you really want an uninitialized buffer -- on purpose this time.

Read it: https://wrocpp.github.io/posts/erroneous-behavior/?utm\_source=reddit&utm\_medium=social&utm\_campaign=post-erroneous-behavior

#cpp #cplusplus #cpp26 #safety #programming

reddit.com
u/filipsajdak — 15 hours ago
▲ 0 r/cpp

Formatting vs Architecture: How formatters are erasing visual cues and hurting codebases

I’m preparing a presentation on how automatic formatters can actually ruin code management over time. This relates heavily to the ongoing discussions about C++ memory safety and why some people see it as a critical issue while others don't get the fuss since basic memory allocation isn't that hard.

Memory issues are usually just a symptom of architectural failure, not a lack of developer skill in handling allocations. A messy architecture turns minor oversights into catastrophes. That's when hidden memory leaks or memory corruption become critical safety flaws and crashes.

I often think about the (nowadays) hated Hungarian Notation. Love it or hate it, it made developers extremely efficient because it provided immediate visual cues. Developers who actively care about the visual shape of text think completely differently about code structure. If you look at Charles Simonyi's other work, it’s clear how much focus he had on architecture.

Formatters can be an absolute disaster for architecture. It has become a religion in development teams that everything must be run through Prettier or Clang-Format to the letter. But the price we pay is that formatters erase all opportunities for visual cues regarding architecture and layers.

Architecture is WAY more important than formatting.

Code is text. By deliberately allowing flexibility in how to format, we can highlight major patterns and make code much easier to reason about. When a formatter forces all code through the same rigid, mechanical template, all code looks identical. The architecture becomes invisible. Ironically, this causes codebases to rot because developers in the team can no longer see where the architectural boundaries actually are.

Formatting in itself isn't bad, but it must be a formatting style that elevates the architecture and allows for human semantic grouping. The opposite is dangerous.

As far as I know, there is no formatter out there today that is anywhere near capable of handling the flexibility required to actually make architecture visible in code.

What are your thoughts on this? Have formatters made us blind to the actual structure and layer belonging of our code?

EDIT

To those of you who only see problems with this approach: what is your actual alternative for managing cognitive load at scale?

The common stance seems to be "just write code however you want, as long as the automatic formatter makes the layout look consistent."

But formatting only fixes cosmetic consistency, it doesn't fix structure, architectural boundaries, or intent. If you believe that naming conventions, prefixes, and semantic text layouts are useless, you are essentially advocating for visual anarchy disguised as "clean text". How does a mechanical linter help a new developer navigate architectural layers in a large codebase if the code itself provides zero visual cues about where the boundaries go?

reddit.com
u/gosh — 17 hours ago
▲ 0 r/cpp

Top 3 spec items for a C++ Framework?

If someone where setting out to create something on the scale of Qt. A comprehensive application framework in C++. (Yes, they'd be crazy)
What would be the top 3 (or more) things you'd say were MUST or MUST NOT features?
For example MUST run on my 2MB wrist watch or MUST not use exceptions.

reddit.com
u/Ok_Independence_9841 — 16 hours ago
▲ 39 r/cpp

C++ Jobs - Q3 2026

Rules For Individuals

  • Don't create top-level comments - those are for employers.
  • Feel free to reply to top-level comments with on-topic questions.
  • I will create top-level comments for meta discussion and individuals looking for work.

Rules For Employers

  • If you're hiring directly, you're fine, skip this bullet point. If you're a third-party recruiter, see the extra rules below.
  • Multiple top-level comments per employer are now permitted.
    • It's still fine to consolidate multiple job openings into a single comment, or mention them in replies to your own top-level comment.
  • Don't use URL shorteners.
    • reddiquette forbids them because they're opaque to the spam filter.
  • Use the following template.
    • Use **two stars** to bold text. Use empty lines to separate sections.
  • Proofread your comment after posting it, and edit any formatting mistakes.

Template

**Company:** [Company name; also, use the "formatting help" to make it a link to your company's website, or a specific careers page if you have one.]

**Type:** [Full time, part time, internship, contract, etc.]

**Compensation:** [This section is optional, and you can omit it without explaining why. However, including it will help your job posting stand out as there is extreme demand from candidates looking for this info. If you choose to provide this section, it must contain (a range of) actual numbers - don't waste anyone's time by saying "Compensation: Competitive."]

**Location:** [Where's your office - or if you're hiring at multiple offices, list them. If your workplace language isn't English, please specify it. It's suggested, but not required, to include the country/region; "Redmond, WA, USA" is clearer for international candidates.]

**Remote:** [Do you offer the option of working remotely? If so, do you require employees to live in certain areas or time zones?]

**Visa Sponsorship:** [Does your company sponsor visas?]

**Description:** [What does your company do, and what are you hiring C++ devs for? How much experience are you looking for, and what seniority levels are you hiring for? The more details you provide, the better.]

**Technologies:** [Required: what version of the C++ Standard do you mainly use? Optional: do you use Linux/Mac/Windows, are there languages you use in addition to C++, are there technologies like OpenGL or libraries like Boost that you need/want/like experience with, etc.]

**Contact:** [How do you want to be contacted? Email, reddit PM, telepathy, gravitational waves?]

Extra Rules For Third-Party Recruiters

Send modmail to request pre-approval on a case-by-case basis. We'll want to hear what info you can provide (in this case you can withhold client company names, and compensation info is still recommended but optional). We hope that you can connect candidates with jobs that would otherwise be unavailable, and we expect you to treat candidates well.

Previous Post

reddit.com
u/STL — 1 day ago
▲ 0 r/cpp

Windows doesn't have fork(), so I faked copy-on-write with VirtualProtect + exception handling to snapshot an in-memory KV store

Was messing around trying to figure out how Redis does BGSAVE without blocking, and it comes down to fork() + COW on Linux — the OS shares pages between parent/child and only copies a page when someone writes to it. Windows has no fork(), so there's no free lunch here.

Ended up building a small toy project (Veyr) to see if I could fake the same behavior in user space on Windows. Wrote it up here if anyone's interested: https://satadeepdasgupta.medium.com/the-windows-machine-doesnt-have-fork-so-we-built-one-b10e1357aa4f

Short version of how it works:

• put the whole dataset in one big VirtualAlloc'd arena

• when snapshotting starts, VirtualProtect the arena to PAGE_READONLY

• any write thread that touches it now takes a hardware access violation

• catch that in a Vectored Exception Handler, copy the 4KB page to a shadow buffer before it changes, flip that page back to RW, resume execution

• background thread walks the arena and writes shadow pages for anything that got touched, live pages for anything that didn't

The first version I tried leaked memory into deadlocks because my handler was calling malloc for the shadow page allocation, and if the frozen thread happened to be holding the heap lock when it faulted, it just... never came back. Fixed by only calling VirtualAlloc directly inside the handler, never touching the normal allocator. Kind of an obvious fix in hindsight but took me a minute to figure out why it was randomly hanging.

Also built a lock-free hash map for it (atomic pointer swap per slot, immutable entries so there's no torn reads) since the snapshotting trick doesn't matter much if the map itself is the bottleneck.

Ran redis-benchmark against it and against Memurai (Redis-compatible Windows server) on the same box, same command. Veyr came out ahead by a decent margin but it's only doing GET/SET, no persistence format, no ACLs, none of the actual feature surface Memurai has, so take that as "minimal special-purpose thing beats general-purpose thing" rather than any real claim about which engine is better. Numbers are in the post if curious, didn't want to just paste a screenshot and let it become the whole conversation.

Known gap I haven't fixed: the map doesn't free old entries on overwrite, it just orphans them in a bump arena. Works fine for a benchmark, would leak forever under real sustained traffic. Need to add epoch-based reclamation or hazard pointers or something before this is anything other than a toy.

Source's up if anyone wants to poke holes in it: github.com/satadeep3927/veyr

Happy to be told I reinvented something that already exists, wouldn't be the first time.

u/SatadeepDasgupta — 2 days ago
▲ 47 r/cpp+5 crossposts

YCETL: a compile time STL like template library to generate data structures that can be used at runtimes

I posted this days ago but the 'automated admins took it down saying was generated by AI' as the formulation was maybe too academic. Trying now with other words.
Short storry: I wanted to generated python glue code for webgpu based on webgpu header. After exploring libclang and generating correct results, I wanted something more generic, more 'built in into C++'. At the beginning I thought will be easy with constexpr compile time tricks, but turned out the compile time 'runtime' is very restrictive. And I solved the challenges with ycetl. https://github.com/zokrezyl/ycetl

This is not a toy project, it is work of couple of months, fight with windmills of compile time runtime. If you see issues that can make it production ready, please share.

u/Ok_Path_4731 — 3 days ago
▲ 23 r/cpp

C++ Show and Tell - July 2026

Use this thread to share anything you've written in C++. This includes:

  • a tool you've written
  • a game you've been working on
  • your first non-trivial C++ program

The rules of this thread are very straight forward:

  • The project must involve C++ in some way.
  • It must be something you (alone or with others) have done.
  • Please share a link, if applicable.
  • Please post images, if applicable.

If you're working on a C++ library, you can also share new releases or major updates in a dedicated post as before. The line we're drawing is between "written in C++" and "useful for C++ programmers specifically". If you're writing a C++ library or tool for C++ developers, that's something C++ programmers can use and is on-topic for a main submission. It's different if you're just using C++ to implement a generic program that isn't specifically about C++: you're free to share it here, but it wouldn't quite fit as a standalone post.

Last month's thread: https://www.reddit.com/r/cpp/comments/1tulp9b/c_show_and_tell_june_2026/

reddit.com
u/foonathan — 2 days ago
▲ 10 r/cpp+5 crossposts

i need guidance what to do after i finished my firewall project.

hello guys, i just finished my first project which is a NGFW Firewall .
and after testing it on over 40 kinds of malwares it was really successful against polymorphics and other kind of malwares i need someone to guide me should i publish it as an Open-source firewall or should i wait for someone to get interested in it and maybe he could buy it from me .
.
github.com/manaf-dev1/sentinel-firewall
this is the firewall its just a readme i update everytime i accomplish something and you'll find the latest update of what i've done .
i wish if a real expert could guide me what to do with it because in my region there's no support for this kind of stuff and they're just interested in famous providers . such as PaloAlto , etc...

github.com
u/ALDulaimi-Dev — 2 days ago
▲ 0 r/cpp

Why use c++ over c for game development?

Isn't c++ overkill for most games? I think with good architectural decisions you can make decent 2d and 3d games using only what's available in c without the higher level concepts introduced in c++? Do you think I'm being stupid here? Am I missing something? I'm only just starting to learn c making simple games leaning heavily on Raylib and ECS architecture.

reddit.com
u/HolidayNo84 — 4 days ago
▲ 204 r/cpp+2 crossposts

Redundancy seen in AAA game engines

Ever wonder what the compiler actually spits out when you use those generic math library functions for every single case because you couldn't be bothered enough writing a specialized, hardcoded implementation?

I've been reversing game engines to study how they constructed their fundamental Transformation matrices and handled temporal jitter logic when I spotted a lot of avoidable overhead and "over-engineering" across multiple engines, the main culprit being the heavy, general-purpose math wrappers being used everywhere for every little thing... That said expect no performance gain this is simply for fun that I wrote this blog!

I’ll theorize how the original C++ code was written, show the unoptimized reality of what the compiler spat out, and then showcase how it could have been better optimized.

zero-irp.github.io
u/zer0_1rp — 4 days ago
▲ 19 r/cpp

is there any material available that do code review of projects?

Hi All I am learning C++ and wants to create/contribute C++ projects. I know most of modern cpp concepts(till c++17) but haven't confidence and also I want to follow some clean coding standards.

If there any material related to code review available on YouTube/Udemy/Coursera or anywhere that will be very helpful to me.

so, please tell if anyone have experience into this

Thanks in Advance to all of you !!

reddit.com
u/rangbaaz125 — 3 days ago
▲ 0 r/cpp

Anyone using Claude to reverse-engineer legacy C/C++ systems? My sequence-diagram agents are missing or inventing call paths

I I inherited a legacy C/C++ software that lacks comprehensive documentation.

To address this, I’ve developed agents that generate sequence diagrams for specified features.

However, these agents have been implemented for numerous features, but they either don’t document every sequence or they document incorrect sequences and features for sequence diagrams.

Here’s what I’m doing to resolve this issue, but it’s not working.

  1. I’ll create a top-level breakdown structure of the software stack and the current code.
  2. I’ll identify the features that are part of the software stack and determine which specific API initiates those features.

Any input or help would be greatly appreciated.

reddit.com
u/csthbso_-862b — 3 days ago
▲ 25 r/cpp

Pure Virtual C++ 2026 lineup: free online conference on July 21

Microsoft is hosting the annual Pure Virtual C++ conference on Tuesday, July 21, starting at 16:00 UTC. This is a free, one-day, online event. The featured talks:

  • C++ Semantic Awareness in the CLI: From Project Load to Code Change (Sinem Akinci)
  • C++/WinRT: Build Faster and Smaller with C++20 Modules (Ryan Shepherd)
  • Mind the Gap: C++/Rust Interop (Victor Ciura)
  • From Completions to Agents: AI-Driven C++ in Visual Studio (Augustin Popa)
  • Cut Your Build Times Without Becoming a Build Expert (David Li)

There's also on-demand content planned, including topics on C++ dependency management, the state of C++ conformance in MSVC, and Sample Profile-Guided Optimization. Sessions will be uploaded to the Visual Studio YouTube channel afterward for anyone who can't watch live.

devblogs.microsoft.com
u/augustinpopa — 3 days ago
▲ 60 r/cpp

What's the fastest c++ build pipeline you've achieved ?

Trying to get a realistic picture of what's actually achievable on a large c++ codename before we commit to anything. We're at 450k LOC, full clean builds sitting around at 55 minites on a 16-core machine. Incremental builds are manageable but a full rebuild after a branch switch or a CI run is painful. We've moved to Ninja, cache is in place, worst of the header bloat is cleaned up. At this point it feels like We're pushing against a hardware ceiling rather than a tooling one. Distributed compilation seems like the logical next move , but I'm also wondering if there's something between local optimizations and a full distrubuted setup that actually moves the needle. Anyone hit similar numbers at this scale and seen meaningful improvements?

reddit.com
u/renren832 — 5 days ago
▲ 0 r/cpp

I’m 17, I love C++, but I feel lost trying to get my first remote programming job

I’m 17 and I genuinely love C++ because it is difficult in many ways. It constantly challenges you to think deeply, and it has a wide range of applications, like robotics, game development, embedded systems, and similar fields.

The problem is that all of these jobs seem extremely hard to find, especially for someone my age. I don’t really know what to do. I would love to get my first remote job, but there are almost no opportunities, at least from what I see on X/Twitter. A friend recommended cold emailing, and some people I know said they got jobs that way, but I honestly don’t know how to approach it.

I don’t know if I sound pessimistic, but programming has become the center of many jobs that attract scammy behavior. Sometimes I feel like, in the job market, I will be treated the same as someone who just watched a YouTube video, heard that programmers are highly paid, and decided that programming is a great work-from-home career.

There are just too many of us.

When I think about how many people I knew on Discord who were depressed and only wanted a remote job so they could use AI to do the work, it makes me feel even more confused. Then I look at people on YouTube,Instagram,tik-tok making money from the most ridiculous things, and it honestly feels like people today don’t even think deeply anymore.

Times feel very hard, and I don’t know what I should do.

My friends told me to try cold emailing, and they say they got work that way, but I really don’t know what I am supposed to become in today’s world: a good person and a real programmer, or just another scammy person who only wants money, like it feels many people are doing now.

I know this might sound negative, but I’m being honest. I like programming, especially C++, and I want to build real skills. I just don’t know what the realistic path is for someone who is 17, has no degree, wants remote work, and is interested in hard fields like robotics, game dev, embedded systems, or low-level programming.

Any honest advice from people who have been in a similar position would mean a lot.

reddit.com
u/Zestyclose-Paint-418 — 5 days ago
▲ 11 r/cpp+1 crossposts

Part 2: Modernizing a tiny C++ unit-testing framework after 25 years

Recently I shared Part 1 describing a tiny unit-testing framework I originally wrote around 2000 for teaching C++.

Part 2 finishes the series by modernizing the implementation using facilities that didn’t exist back then, including std::source_location and inline variables, while keeping the framework intentionally small.

This isn’t intended as a replacement for Catch2, GoogleTest, or doctest. Those solve much bigger problems. The point here is to explore how far modern C++ lets you go with very little code.

I’d be interested in comments from anyone who’s built testing infrastructure or has opinions about minimalist testing frameworks.

Part 2:
https://freshsources.com/code-capsules/test-part2/

Part 1:
https://freshsources.com/code-capsules/test-part1/

reddit.com
u/Weary-Inspector-4297 — 4 days ago
▲ 43 r/cpp+1 crossposts

Stackful fibers with 3.6ns context switch. Silk fibers.

I just read an article about Silk, the new stackful fibers engine from Clickhouse. It can switch stackful fibers at an amazing 3.6ns and does not allocate on steady state.

Maybe asio could reuse some of the knowledge for the linux/io_uring backend (not sure it applies to the specific case since Boost.asio focuses nowadays on stackless, though it has a fibers and a stackful coros backend also).

clickhouse.com
u/germandiago — 6 days ago
▲ 78 r/cpp

Introducing the Boost Documentary! Teaser & CppCon Preview

"If I were to tell a story about Boost, I'd start with the people."

Today we're sharing the official teaser for the Boost documentary. A film about the people, the politics, and decades of work behind possibly the most important open source library most people have never heard of.

Teaser link – https://youtu.be/87jvuDbnwqQ

The documentary looks at:

  • Boost as a kind of "app store for C++, 30 years early"
  • What decades of open source dedication looks like up close
  • The honest, sometimes uncomfortable dynamics of how proposals and people move through the C++ committee

There will be a preview screening at CppCon 2026 for all attendees. So if you're going to be in Aurora, CO September 16, 2026, please join us!

u/boostlibs — 6 days ago
▲ 37 r/cpp

Modern GPU Programming with SDL3, Wed, Jul 8, 2026, 6:00 PM (MDT)

SDL has long been a convenient portability layer for windows, input, audio, and simple rendering. SDL3 adds a new GPU API that exposes modern graphics and compute functionality through a portable interface over native backends such as Vulkan, Direct3D 12, and Metal.

This month, Richard Thomson will give us a gentle introduction to SDL3 GPU programming. We will look at what SDL3 GPU is, what problem it is trying to solve, and how it compares to using OpenGL, Vulkan, Direct3D, or Metal directly.

We will build up a small C++ example that creates an SDL window, creates a GPU device, uploads data, creates shaders and pipelines, records command buffers, renders to a swapchain texture, and optionally runs a simple compute pass.

We will also cover the practical parts of using the API in a C++ project: consuming SDL3 from vcpkg, organizing shader assets, dealing with backend-specific shader formats, and deciding when SDL_shadercross is useful. Along the way we will point out the parts of the API that feel familiar to Vulkan/D3D12/Metal programmers and the parts that SDL deliberately simplifies.

This is not a deep dive into graphics theory. The goal is to understand whether SDL3 GPU is a useful middle ground for C++ applications that need more than SDL_Renderer, but do not want to own separate graphics backends for every platform. Topics include:

  • Creating an SDL3 GPU device
  • Swapchains, textures, buffers, and transfer buffers
  • Graphics pipelines and render passes
  • Compute pipelines and storage buffers/textures
  • Shader formats and SDL_shadercross
  • vcpkg and CMake integration
  • Debugging with RenderDoc and backend validation layers
  • Where SDL3 GPU fits, and where it does not

No prior Vulkan, Direct3D 12, or Metal experience is required, but basic familiarity with C++, CMake, and graphics concepts such as textures and shaders will be helpful.

This will be an online meeting, so drinks and snacks are on you!

Join the meeting here: https://meet.xmission.com/Utah-Cpp-Programmers

Watch previous topics on the Utah C++ Programmers YouTube channel: https://www.youtube.com/@UtahCppProgrammers

Future topics: https://utahcpp.wordpress.com/future-meeting-topics/ Past topics: https://utahcpp.wordpress.com/past-meeting-topics/

meetup.com
u/LegalizeAdulthood — 5 days ago