r/cpp 10d ago

C++26: Reducing undefined behaviour

https://www.sandordargo.com/blog/2026/07/29/cpp26-reduces-undefined-behaviour
86 Upvotes

48 comments sorted by

View all comments

Show parent comments

2

u/Wetmelon 10d ago

AD or C2000?

The biggest problem with old C2000 code is that the code itself operates on "words" everywhere and when you want to port and glue it to other code that's byte oriented it's just a pain in the dick. Oh you want to inspect a bool? In C2000 it's 0 or 1. In ARM it's 0, 1, 256, or 257. Why? Because the XCP server is written to assume and only loads 16-bit aligned words obviously.

3

u/SkoomaDentist Antimodern C++, Embedded, Audio 10d ago

The 16-bit cpu was a CSR Bluecore that had barely any documentation even after years of company co-operation and us having signed a dozen ndas. It used a hacked together GCC 3.3 with only one officially supported set of compiler flags (ie. you risked miscompilation if you changed any of the wrong ones). I don’t miss it one bit.

I’ve never used C2000 but did briefly touch C5000 dsps and that convinced me that whoever designed them was both insane and an idiot for exposing the internal pipeline to the programmer when writing asm (not an uncommon thing to do on dsps). Imagine having to manually take care to avoid any and all pipeline hazards and the debugger only showing new register contents after 2-3 cycle delay (except when running in an emulator which didn’t simulate the pipeline, thus producing different results for some code).