#UndefinedBehaviour

C++Nowcppnow
2025-04-16

C++Now 2025 SESSION ANNOUNCEMENT: Undefined Behavior From the Compiler’s Perspective by Shachar Shemesh

schedule.cppnow.org/session/20

Register now at cppnow.org/registration/

C++Nowcppnow
2025-03-24

C++Now 2025 SESSION ANNOUNCEMENT: Undefined Behavior From the Compiler’s Perspective by Shachar Shemesh

schedule.cppnow.org/session/20

Register now at cppnow.org/registration/

Stephane L Rolland-Brabant ⁂⧖⏚stphrolland@mathstodon.xyz
2024-10-19

@chakie

I personnally never count upon miracle segfaults to detect errors, as it is simply Undefined Behaviour #undefinedbehaviour in C/C++, so you cannot know what happens in such cases.

But you are right, often you can get segfaults to indicate you early that a corruption is happening.

It remains a powerful technique for optimizing speed. Often, one cannot gain on every level ;-)

I was just talking about it. It is not a recommended way to do it.

If your allocation is not in a bottleneck, it is a fuss you don't have to worry about.

I rather got a chuckle out of this #LWN article, which can sort of be summarized as "CPU architectures involving time-travel result in undefined behaviour".

lwn.net/Articles/993484/

#TimeTravel #MemoryModel #C #programming #C++ #UndefinedBehaviour

2023-10-25
Ivan Enderlin 🦀hywan@fosstodon.org
2023-02-04

Falsehoods programmers believe about undefined behaviour, predr.ag/blog/falsehoods-progr.

The article explains what is an undefined behaviour exactly. It’s funny.

#UndefinedBehaviour

David JONESdrj@typo.social
2023-02-03

The basic problem with C is that the committee have been asleep at the wheel for 30 years. As soon as UB began to be interpreted as "the compiler will now do impossible things" they should have stepped in and said "actually we mean that _some value_ is produced, but we do not care to specify what" (or a trap is raised, to keep SGI on board). That covers arithmetic anyway.
Sure for pointers and longjmp you do need "truly undefined", but even that could be profiled.

1/

#UndefinedBehaviour

2022-11-28

My problem with undefined behavior, isn't that there are things in C/C++ you can't do. Every programming language has things you can't do.

My problem is that the compiler and runtime isn't required to tell you that you're not allowed to do it.

Indeed, some forms of UB don't appear to be suspicious at all. A programmer would be forgiven to think they are allowed by the language.

And then when the program breaks we call that human error, but it is, in reality, bad design, to borrow an idea from Don Norman.

It's like a push-only door that's labelled "pull"!

#normanDoors #programming #cprogramming #cpplang #cplusplus #design #undefinedbehavior #undefinedbehaviour

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst