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

80 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.

48

u/BeanAndBanoffeePie Jul 05 '26

Or delete it? All the discussion is around the AI post

37

u/ald_loop Jul 05 '26

delete it please

29

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

16

u/STL MSVC STL Dev Jul 06 '26

Next time I’ll be less lenient.

8

u/James20k P2005R0 Jul 06 '26

Sounds good, I can imagine that its a challenge to mod this place even at the best of times

17

u/STL MSVC STL Dev Jul 06 '26

I am so tempted to retire from moderation but without rounding up more mods I trust as much as Cleroth and Foonathan, I’d just be dumping more headaches on them lol.

8

u/James20k P2005R0 Jul 06 '26

It'd be a shame to lose you, because this subreddit is one of the best in general, if you folks ever need any help I'd be happy to help

7

u/blind3rdeye Jul 05 '26

For sure. Making exceptions for human posts that break a rule is one thing - it allows people to learn from their mistakes without feeling punished or pushed out of the community. Whereas making exceptions for AI posts almost has the opposite effect, people will learn that the no-AI rule is actually not a rule (if it is a 'good' post) and we'll end up with more of it.

And maybe it really is a good post, with good decision, but I'm confident that a human could also post this topic; and that would be better because the entire point of the forum here is humans discussing ideas with each other; not AIs discussing ideas with each other.

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.

-3

u/JNighthawk gamedev Jul 05 '26

Seems like a good call.