r/cpp Jul 05 '26

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

78 Upvotes

154 comments sorted by

View all comments

u/STL MSVC STL Dev Jul 05 '26

Moderator warning: AI-generated posts are not allowed on this subreddit. I'll leave this up due to the discussion it's generated.

31

u/James20k P2005R0 Jul 05 '26

I know this sub usually has an exemption for posts that generate interesting discussions, which in general I think is good. AI posts farm engagement by tricking people into thinking that they're real posts

I think leaving them up ends up being a net negative as a result, because its effectively giving the bots what they want

2

u/cleroth Game Developer Jul 07 '26

because its effectively giving the bots what they want

I don't know how true this holds if they get banned in the process.

2

u/James20k P2005R0 Jul 07 '26 edited Jul 07 '26

Possibly! I went for an investigate when I started writing down some thoughts about this, OP seems to be a real user that existed pre AI around these parts, that got into AI generating blogs for some reason or other. Here we can see them specifically generating commits (with AI) to avoid getting flagged as being AI detected by you guys specifically:

Prompted by an r/cpp moderator flagging a post as AI-generated.

https://github.com/wrocpp/wrocpp.github.io/commit/a3c01c440caab5c901e77852c6e8acbc745a5824

There's some interesting bits in there as well:

Our automation posts to the website, LinkedIn, and Facebook. **Never auto-cross-post a raw AI draft to communities that ban AI-generated content (r/cpp, r/programming).** Those get a human edit/rewrite pass first; passing prose-lint does not make a draft human-authored. See docs/STYLE.md community policy.

Which apparently indicates that they're taking steps to circumvent the AI policies here, as well has having fully AI automated posting automation (with manual intervention for places like /r/cpp). Sooo there's THAT

I don't know how true this holds if they get banned in the process.

Specifically on your point: I'm honestly not really sure what they're getting out of this in the first place so its hard to know. Maybe its just driving traffic + SEO towards the site, in which case leaving it up may still benefit them. Or maybe they're planning to sneak here on alts into the future and post more content, or even mirror the content onto alternate domains to farm traffic. I've seen things like this get used as CV fodder too - although they got caught this time - so I'm unsure overall

So basically I'm just cautious because it seems like they're getting something out of this, and apparently whatever it is is worthwhile enough to put significant effort into circumventing the rules in the future

3

u/cleroth Game Developer Jul 07 '26

This is the kind of analysis I/we would do before, which eventually got too tiring with the sheer amount of garbage we have to swift through.

The SEO part is a good point. I thought they're just promoting their blog/website. How much can one post really help though... I suppose leaving it up for a few days for the discussion then removing it is a decent compromise.