Lemmy: Bestiverse
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
RSS BotMB to Lobste.rsEnglish · 9 hours ago

Zig asserts are not C asserts

cryptocode.github.io

external-link
message-square
0
fedilink
1
external-link

Zig asserts are not C asserts

cryptocode.github.io

RSS BotMB to Lobste.rsEnglish · 9 hours ago
message-square
0
fedilink
I recently came across a piece of code in a Ziggit.dev post that gave me pause: pub fn putOne(q: *@This(), io: Io, item: Elem) Cancelable!void { assert(try q.put(io, &.{item}, 1) == 1); } pub fn getOne(q: *@This(), io: Io) Cancelable!Elem { var buf: [1]Elem = undefined; assert(try q.get(io, &buf, 1) == 1); return buf[0]; } …which led me to ask the following: Just a quick side quest: Doesn’t the assert here risk put and get calls being optimized away?

Comments

alert-triangle
You must log in or register to comment.

Lobste.rs

lobsters

Subscribe from Remote Instance

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: !lobsters@lemmy.bestiver.se
lock
Community locked: only moderators can create posts. You can still comment on posts.

RSS Feed of lobste.rs

Visibility: Public
globe

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

  • 27 users / day
  • 121 users / week
  • 408 users / month
  • 1.29K users / 6 months
  • 2 local subscribers
  • 283 subscribers
  • 9.6K Posts
  • 511 Comments
  • Modlog
  • mods:
  • patrick
  • RSS Bot
  • BE: 0.19.5
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org