OpenRiver Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
CodyIT@programming.dev to C++@programming.devEnglish · 2 months ago

C++26: Trivial infinite loops are no longer undefined behaviour

www.sandordargo.com

external-link
message-square
0
link
fedilink
  • cross-posted to:
  • hackernews@lemmy.bestiver.se
1
external-link

C++26: Trivial infinite loops are no longer undefined behaviour

www.sandordargo.com

CodyIT@programming.dev to C++@programming.devEnglish · 2 months ago
message-square
0
link
fedilink
  • cross-posted to:
  • hackernews@lemmy.bestiver.se
Let’s start with a question! Is this program well-defined? 1 2 3 4 int main() { while (true) ; } If you said yes, you’d be wrong — at least before C++26. A while (true); loop with no side effects used to be undefined behaviour. Compilers were free to assume it terminates, and some — Clang in particular — would optimize it away entirely, with spectacular consequences: 1 2 3 4 5 6 7 8 9 10 11 // https://godbolt.org/z/WYMxxeW1T #include int main() { while (true) ; } void unreachable() { std::cout << "Hello world!" << std::endl; } In…
alert-triangle
You must log in or register to comment.

C++@programming.dev

cpp@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !cpp@programming.dev

The center for all discussion and news regarding C++.

Rules

  • Respect instance rules.
  • Don’t be a jerk.
  • Please keep all posts related to C++.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 8 users / day
  • 8 users / week
  • 8 users / month
  • 8 users / 6 months
  • 0 local subscribers
  • 2.41K subscribers
  • 49 Posts
  • 0 Comments
  • Modlog
  • mods:
  • lysdexic@programming.dev
  • Nihili0@programming.dev
  • BE: 0.19.21
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org